Home >>Ngx Bootstrap Tutorial >Ngx Bootstrap Environment Setup

Ngx Bootstrap Environment Setup

Ngx Bootstrap Environment

You will learn in detail about setting up the ngx-bootstrap working environment on your local computer in this chapter. Make sure you have Node.js and npm and angular enabled on your system, as ngx-bootstrap is mainly for angular projects.

Create an angular project

To test ngx-bootstrap components using the following commands, first build an angular project.

ng new ngxbootstrap

An angular project named ngxbootstrap will be developed.

Add ngx-bootstrap as dependency

The following command can be used to instal ngx-bootstrap for a newly developed project.

npm install ngx-bootstrap

The following performance can be observed once ngx-bootstrap is installed successfully.

+ ngx-bootstrap@5.6.1
added 1 package from 1 contributor and audited 1454 packages in 16.743s

Now, to evaluate if bootstrap works fine with Node.js, use the following command to build a test component –

ng g component test
CREATE src/app/test/test.component.html (19 bytes)
CREATE src/app/test/test.component.spec.ts (614 bytes)
CREATE src/app/test/test.component.ts (267 bytes)
CREATE src/app/test/test.component.css (0 bytes)
UPDATE src/app/app.module.ts (388 bytes)

Clear and update the content of app.component.html with the following content.



Update the content of app.module.ts to include the Accordion Module ngx-bootstrap. In subsequent chapters, we'll add other modules. Update the subsequent content.


import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { TestComponent } from './test/test.component';
import { AccordionModule } from 'ngx-bootstrap/accordion'
   declarations: [
   imports: [
   providers: [],
   bootstrap: [AppComponent]
export class AppModule { }

Updating the index.html content to include bootstrap.css. Update the subsequent content.


<!doctype html>
<html lang="en">
      <meta charset="utf-8">
      <base href="/">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="icon" type="image/x-icon" href="favicon.ico">
      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">

We'll update the test component to use the ngx-bootstrap component in the next chapter.

No Sidebar ads