从角度2中的ng-bootstrap模块中排除组件2

从角度2中的ng-bootstrap模块中排除组件2

问题描述:

我想从角度2中的ng-bootstrap模块导入某些特定组件。 我可以这样做吗?从角度2中的ng-bootstrap模块中排除组件2

我有从现有的ng-bootstrap组件创建的自定义标签集。 导入ng-bootstrap后,我得到模块重复错误。

我该如何处理这个问题。

很容易:只需从ng-bootstrap导入单个模块,而不是导入整个NgbModule。例如,只进口警报相关的功能,你会怎么做:

import { NgbAlertModule } from '@ng-bootstrap/ng-bootstrap/alert/alert.module'; 

... 

@NgModule({ 
    imports: [BrowserModule, NgbAlertModule.forRoot()], 
    declarations: [App] 
    bootstrap: [App] 
}) 
export class AppModule {} 

当然,你将不得不进口,并列出您正在使用,但这里的好处是,你可以精确地只引用一些事情的所有模块用于您的应用程序。