Integrating Bootstrap 4 and jQuery with Angular 9/8 and Styling the UI With Navbar and Table CSS Classes

  • Author: Ahmed Bouchefra

In this tutorial we'll learn, by example, how to use Bootstrap 4 with Angular 9/8 to build professional UIs.

Angular 9 is the latest version of Angular, when writing this tutorial, and Bootstrap 4 is the latest version of Bootstrap — the most popular CSS framework. You can use Bootstrap to create professional looking interfaces without being a CSS designer.

In this tutorial, we'll particularly look at how to add Bootstrap 4 to Angular projects generated using Angular CLI 9.

In this part, we're going to style an example UI interface with Bootstrap 4, after installing and setting up the framework in the Angular 9 front-end.

In the previous tutorial we’ve:

  • Installed Angular CLI 8.
  • Generated a new front-end application using Angular CLI 9.
  • Created some UI components.

Different Ways to Integrate Bootstrap 4 with Angular 9

There are many ways to add Bootstrap 4 to Angular 9 projects:

  • Installing bootstrap and jquery via npm and add adding scripts and styles to angular.json.
  • Importing bootstrap style and script files in src/index.html. You can use a bootstrap 4 CDN.
  • Installing bootstrap via npm and importing @import "~bootstrap/dist/css/bootstrap.css"; in src/styles.css.
  • Installing and using ng-bootstrap npm install --save @ng-bootstrap/ng-bootstrap: It's a library that contains native Angular components for Bootstrap’s markup and CSS styles. It's not dependent on jQuery or Bootstrap’s JavaScript.

How to Work with This Tutorial?

To complete this tutorial, you'll need to, either:

  • Start with the previous tutorial, which takes you from installing the Angular CLI 9 to calling the RESTful API
  • Clone the font-end project from GitHub and follow the steps in the previous tutorial for setting up the project.
  • Directly follow the steps to integrate Bootstrap 4 in your own Angular 9 project.

How to add Bootstrap 4 to your Angular 9 Front-End?

After seeing different ways to add Bootstrap 4 to Angular 9, let's now style our Angular 9 front-end UI, built in the previous tutorial, with Bootstrap. We'll use the first approach i.e we'll install bootstrap from npm and then we'll include bootstrap.css CSS file, jQuery and Popover.js

Installing Bootstrap 4 and jQuery

Head over to your project, you created in the previous tutorial, navigate inside your Angular 8 front-end application:

$ cd frontend

Next, install bootstrap and jquery from npm using:

$ npm install --save bootstrap jquery

Adding Bootstrap 4 to Angular CLI 9

Next, open angular.json. You should similar content to the following:


"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
    "crmapp": {
    "root": "",
    "sourceRoot": "src",
    "projectType": "application",
    "prefix": "app",
    "schematics": {},
    "architect": {
        "build": {
        "builder": "@angular-devkit/build-angular:browser",
        "options": {
        "outputPath": "dist/crmapp",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/",
        "assets": [
        "styles": [
        "scripts": []

"defaultProject": "crmapp"

Under projects -> architect -> build -> scripts add node_modules/jquery/dist/jquery.min.js and node_modules/bootstrap/dist/js/bootstrap.min.js:

"scripts": [

Under projects -> architect -> build -> styles add node_modules/bootstrap/dist/css/bootstrap.min.css:

"styles": [

That's it. You can now use Bootstrap 4 in your Angular 8 front-end application just lie you would normally do.

Styling Angular Components with Bootstrap 4

Let's take an example. Go ahead and open src/app/app.component.html and update it to add a Bootstrap navigation bar:

<nav  class="navbar navbar-expand-lg navbar-light bg-light">
    <a  class="navbar-brand"  href="#">Angular CRM</a>
    <button  class="navbar-toggler"  type="button"  data-toggle="collapse"  data-target="#navbarSupportedContent"  aria-controls="navbarSupportedContent"  aria-expanded="false"  aria-label="Toggle navigation">
    <span  class="navbar-toggler-icon"></span>
<div  class="collapse navbar-collapse"  id="navbarSupportedContent">
    <ul  class="navbar-nav mr-auto">
        <li  class="nav-item active">
        <a  class="nav-link"  href="#">Home <span  class="sr-only">(current)</span></a>
        <li  class="nav-item dropdown">
        <a  class="nav-link dropdown-toggle"  href="#"  id="navbarDropdown"  role="button"  data-toggle="dropdown"  aria-haspopup="true"  aria-expanded="false">
        <div  class="dropdown-menu"  aria-labelledby="navbarDropdown">
        <a  class="dropdown-item" [routerLink]="'/accounts'"> Accounts </a>
        <a  class="dropdown-item" [routerLink]="'/create-account'"> Create Account </a>
        <div  class="dropdown-divider"></div>
        <a  class="dropdown-item" [routerLink]="'/contacts'"> Contacts </a>
        <a  class="dropdown-item" [routerLink]="'/create-contact'"> Create Contact </a>
        <div  class="dropdown-divider"></div>
        <a  class="dropdown-item" [routerLink]="'/leads'"> Leads </a>
        <a  class="dropdown-item" [routerLink]="'/create-lead'"> Create Lead </a>
        <div  class="dropdown-divider"></div>
        <a  class="dropdown-item" [routerLink]="'/opportunities'"> Opportunities </a>
        <a  class="dropdown-item" [routerLink]="'/create-opportunity'"> Create Opportunity </a>
<div  class="container-fluid">

Now, let's style contact list component. Open src/app/contact-list.component.html and add:

My Contacts
<table  class="table">
<th>First Name</th>
<th>Last Name</th>
<tr *ngFor="let contact of contacts">
    <td> {{ contact.first_name }} </td>
    <td> {{ contact.last_name }} </td>
    <td> {{ }} </td>
    <td> {{ }} </td>
    <td> {{ contact.address }} </td>

This is a screen-shot of the result after adding Bootstrap 4 classes:

Angular 9/8 and Bootstrap 4 tutorial


In this tutorial, we've seen different ways you can use if you want to add Bootstrap 4 to your project and then we have seen by example how to add Bootstrap 4 to our Angular 9/8 front-end application generated with Angular CLI.

Sponsored Links