angular - 将 ng2-bootstrap 添加到 angular2-seed 时,'tab' 不是已知元素错误

标签 angular ng2-bootstrap

我正在尝试将 ng2-bootstrap 添加到 angular2-seed 项目的新克隆中,但我不断收到以下错误(或类似):

Unhandled Promise rejection: Template parse errors: 'tab' is not a known element

我已按照说明进行操作 here并尝试了几种变体,但它就是不想工作。我在其他使用不同版本的 angular2-seed 的项目中使用它,所以可能发生了一些变化,但他们的 wiki 中还没有记录。

我创建了一个 repo 来展示我的问题:https://github.com/danielcrisp/angular2-seed

正如我所说,它是 angular2-seed 的全新克隆,具有以下变化:

$ npm install ng2-bootstrap --save

然后更新配置:

this.SYSTEM_CONFIG_DEV.paths['ng2-bootstrap'] =
  `${this.APP_BASE}node_modules/ng2-bootstrap/ng2-bootstrap.js`;

this.SYSTEM_BUILDER_CONFIG.packages['ng2-bootstrap'] = {
    main: 'ng2-bootstrap.js',
    defaultExtension : 'js'
};

Ng2BootstrapModule 导入到 NgModule 中。

然后我添加了一些标签进行测试。

<tabset>
  <tab>1</tab>
  <tab>2</tab>
</tabset>

如果我从 HTML 中删除选项卡,我不会收到任何错误。如果我尝试其他 ng2-bootstrap 组件,我也会出错,例如

<button type="button" class="btn btn-primary" [(ngModel)]="singleModel" btnCheckbox btnCheckboxTrue="1" btnCheckboxFalse="0">`

最佳答案

事实证明,我需要将 Ng2BootstrapModule 包含到使用它的每个子 NgModule 中,而不仅仅是主根 NgModule

Ng2BootstrapModule 导入 home.module.ts 就成功了。

感谢@mgechev 的回答!

关于angular - 将 ng2-bootstrap 添加到 angular2-seed 时,'tab' 不是已知元素错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39598409/

相关文章:

angular - 如何使用 ComponentRef 从内部销毁我的组件?

css - 样式 ng2-bootstrap 的 typeahead list-items

Angular 2 : Bind observables to input form fields

angular - 如何为 Subject RxJS observable 分配初始值?

javascript - 如何将两个以上的参数传递给模态 ng2 bootstrap

ng2-bootstrap 工具提示内容在特定位置换行

css - 如何使用 ng2-bootstrap 覆盖 angular2 中的 twitter bootstrap 样式

angular - 如何在 Angular 2 及以上版本中实现模态对话框

javascript - 如何以 Angular 验证javascript内容

angular - 有没有更好的方法来构建带有库的 Angular monorepo 应用程序?