Ste*_*n S 9 npm angular-cli angular
我有这个NgModule:
@NgModule({
imports: [
CommonModule
],
exports: [
SP21LoadingBar
],
declarations: [SP21LoadingBar]
})
export class SP21LoadingBarModule { }
Run Code Online (Sandbox Code Playgroud)
Cli告诉我
ERROR in SP21LoadingBarModule is not an NgModule
Run Code Online (Sandbox Code Playgroud)
请注意:如果我把代码放到我的项目中它可以正常工作.但是一旦我从我的项目中取出模块(和组件)并将其放入npm包中,我就会收到该错误.
Angular用于2.3.1,Angular CLI 1.0.0-beta.24,Typescript 2.0.10
小智 4
最终的解决方案:
您必须使用提前编译器 (ngc) 编译您的库。它将添加一些元数据,允许包含该库的项目读取它。
请查看以下链接:
https://angular.io/docs/ts/latest/cookbook/aot-compiler.html https://medium.com/@cyrilletuzi/how-to-build-and-publish-an-angular-module-7ad19c0b4464# .9y88ipdk7
| 归档时间: |
|
| 查看次数: |
8537 次 |
| 最近记录: |