Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Properly setting up angular 7 with ng-bootstrap

Tags:

angular

I'm trying to use ng-bootstrap in my project. I searched the net and found that I need to install bootstrap 4 and ng-bootstrap. I initialized a brand new project and installed:

"@ng-bootstrap/ng-bootstrap": "^5.1.0",

"bootstrap": "^4.3.1"

I was then talled to do on my app.module.ts

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

imports: [NgbModule.forRoot(),
    BrowserModule,
    AppRoutingModule
  ],

The .forRoot() method is unknown and I get the error:

ERROR in src/app/app.module.ts(13,23): error TS2339: Property 'forRoot' does not exist on type 'typeof NgbModule'.

I work with Angular 7.X.

like image 871
Moshik Avatar asked Aug 17 '19 04:08

Moshik


People also ask

Do bootstrap ng do bootstrap in Angular 7?

You can use ng-bootstrap: The Angular version of the Angular UI Bootstrap library which is built from scratch by the ui-bootstrap team using TypeScript and Bootstrap 4 CSS framework. It has two dependencies which are Angular and Bootstrap 4 CSS file. Recently it was updated to use Angular 7.

Can I use Angular and bootstrap together?

Yes, you can use parts of Angular Material and Bootstrap together in the same web or mobile project. Developers need to be careful not to use the same components, which can clash. Angular Material and Bootstrap offer a variety of unique components for great website design.

Does ng bootstrap need bootstrap?

The goal of ng-bootstrap is to completely replace JavaScript implementation for components. Nor should you include other dependencies like jQuery. It is not necessary and might interfere with ng-bootstrap code.


1 Answers

Remove .forRoot(), so that your imports will look like this:

imports: [
    NgbModule,
    BrowserModule,
    AppRoutingModule
],
like image 50
Marco Lackovic Avatar answered Oct 17 '22 18:10

Marco Lackovic