在Angular 2中从ng-bootstrap模块中排除组件 [英] exclude components from ng-bootstrap module in angular 2

查看:93
本文介绍了在Angular 2中从ng-bootstrap模块中排除组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Angular 2的ng-bootstrap模块中导入一些特定的组件. 我能做到吗?

I want to import some specific components from ng-bootstrap module in angular 2. can I do that?

我有从现有ng-bootstrap组件创建的自定义标签集. 导入ng-bootstrap后,出现模块复制错误.

I have custom tabset created from existing ng-bootstrap component. After importing ng-bootstrap I have getting module duplication error.

我该如何处理!!

推荐答案

这很容易:只需从导入单个模块ng-bootstrap ,而不是导入整个NgbModule.例如,仅导入与警报相关的功能,您可以这样做:

It is easy: just import individual modules from ng-bootstrap instead of importing the whole NgbModule. For example to only import alert-related functionality you would do:

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

...

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

当然,您必须导入并列出您正在使用的所有模块,但是这样做的好处是您可以精确地仅引用应用程序中使用的内容.

Of course you would have to import and list all the modules that you are using but the advantage here is that you can precisely reference only things that are used in your application.

这篇关于在Angular 2中从ng-bootstrap模块中排除组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆