Angular – How to add Bootstrap in a project

By | 26/08/2019

In this post, we will see how to add Bootstrap in the Angular project created in the post:
How to consume a Web API in Angular

First of all, we open terminal, go to the directory of the project and we run the command
npm install bootstrap, in order to install Bootstrap.

Then, we open the file src/styles.css and add the following code, in order to import the Bootstrap css file:

@import '~bootstrap/dist/css/bootstrap.min.css';

Finally, we modify the file listusers.component.html:

<p>List of Users</p>
<table class="table">
        <th scope="col">#</th>
        <th scope="col">Id</th>
        <th scope="col">Username</th>
        <th scope="col">TypeUser</th>
        <th scope="col">Create Date</th>
    <tbody *ngFor="let item of lstUsers; index as i"> 

Now, if we run the application (with the command ng serve), this will be the result:

Leave a Reply

Your email address will not be published. Required fields are marked *