Reputation: 3418
I'm new in ng-boostrap and followed their getting started guide. Here's the important part of the code.
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
...
@NgModule({
imports: [
NgbModule.forRoot(),
...
],
Is ng-bootstrap importing all the components like ngb-carousel, ngb-progressbar and etc even though I'm not using it?
There's another bootstrap library, ngx-bootstrap that does importing each of the components like this
import { ModalModule } from 'ngx-bootstrap/modal';
@NgModule({
imports: [ModalModule.forRoot(),
...]
})
export class AppModule(){}
which is also how you import components modules similar in angular material
Can anyone shed some light on this?
Upvotes: 3
Views: 2448
Reputation: 105537
Yes, it imports all components. You can see it here:
@NgModule({
imports: [
NgbAlertModule.forRoot(), NgbButtonsModule.forRoot(), ...
],
exports: NGB_MODULES
})
export class NgbRootModule {
}
@NgModule({imports: NGB_MODULES, exports: NGB_MODULES})
export class NgbModule {
static forRoot(): ModuleWithProviders { return {ngModule: NgbRootModule}; }
}
It's probably done for convenience. Since individual modules are exported as well:
export {
NgbAccordionModule,
NgbPanelChangeEvent,
...
You can import directly only the modules you're interested in.
Upvotes: 5