aJaysanity
aJaysanity

Reputation: 165

Ngb-xx is not a known element

I am trying to use the ngb bootstrap on my Angular project. Every components on ngb throws me an error

enter image description here

My package.json

enter image description here

and my app.module.ts

enter image description here

Did I do something wrong? I followed and read the instructions carefully.

Upvotes: 0

Views: 1606

Answers (2)

dota2pro
dota2pro

Reputation: 7856

You have to import into the module you are using for the component , Bootstrap Module as it is mentioned in the docs

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

@NgModule({
  ...
  imports: [NgbModule, ...],
  ...
})
export class YourAppModule {
}

It works in this example https://stackblitz.com/edit/angular-d9uwjh?file=src%2Fapp%2Fdatepicker-basic.module.ts

Upvotes: 2

Aniruddha Das
Aniruddha Das

Reputation: 21698

Make sure the module is imported into your module in which the component going to use the Ngb-xx component. Means if you have a child component which uses Ngb component, include your Ngb module not in app module but if you are not using shared module, import it in the app module

With the latest version if Ngb-bootstrap, you need to only import the module which you want to use not the whole module like if you need accordian component, you can only import NgbAccordian module

Upvotes: 0

Related Questions