ng-bootstrap 是否导入所有组件

Is ng-bootstrap importing all the components

我是 ng-boostrap and followed their getting started 指南的新手。这是代码的重要部分。

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

@NgModule({
  
  imports:      [ 
   NgbModule.forRoot(),
    ...
   ],

ng-bootstrap 是否导入了所有组件,如 ngb-carousel、ngb-progressbar 等,即使我没有使用它?

还有另一个 bootstrap 库,ngx-bootstrap 像这样导入每个组件

import { ModalModule } from 'ngx-bootstrap/modal';
@NgModule({
  imports: [ModalModule.forRoot(),
   ...]
})
export class AppModule(){}

这也是您导入与 angular material

类似的组件模块的方式

任何人都可以阐明这一点吗?

是的,它导入了所有组件。可以看到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}; }
}

可能是为了方便。由于还导出了单个模块:

export {
  NgbAccordionModule,
  NgbPanelChangeEvent,
  ...

您可以只直接导入您感兴趣的模块。