我正在使用angular2和ng2-bootstrap。
在我的module.ts中,我这样声明
import { Ng2BootstrapModule, AlertModule } from 'ng2-bootstrap';
imports: [ BrowserModule,
...,
Ng2BootstrapModule.forRoot(),
AlertModule.forRoot(),
... ]在我的组件模板中,我这样声明:
测试警报
我的systemjs.config.js:
map:{
...,
'moment': 'npm:moment',
'ng2-bootstrap': 'npm:ng2-bootstrap',
...
},
packages: {
...,
'moment': { main: 'moment.js', defaultExtension: 'js' },
'ng2-bootstrap': { format: 'cjs', main: 'bundles/ng2-bootstrap.umd.js', defaultExtension: 'js' },
...
}但是我得到了这个错误:
Unhandled Promise rejection: Template parse errors:
'alert' is not a known element:
1. If 'alert' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.我错过了什么。请帮我解决这个问题。我花了几个小时寻找解决方案,但没能解决。
提前谢谢。
发布于 2017-04-06 22:19:26
如果您需要datepicker和alert,请将其导入
import { DatepickerModule, AlertModule } from 'ng2-bootstrap';
imports: [ BrowserModule,
...,
DatepickerModule.forRoot(),
AlertModule.forRoot(),可能发生的情况: Angular需要在相应子模块中导入用于渲染的模块
https://stackoverflow.com/questions/43154976
复制相似问题