【发布时间】:2017-07-21 22:34:06
【问题描述】:
下面是我的创建动态模块的初始代码:
protected createComponentModule(componentType: any) {
@NgModule({
imports: [
ComponentModule
],
declarations: [
componentType
],
})
class RuntimeComponentModule {
}
return RuntimeComponentModule;
}
虽然我要在下面的代码上实现 AOT,但它会抛出错误:
找不到“RuntimeComponentModule”的 NgModule 元数据
我通过更改以下代码找到了一些 Articals 的解决方案,并且我的错误消失了:
default class RuntimeComponentModule
{
}
但是出现了新的错误,它说:
修饰符不能出现在这里
它不允许我在方法中装饰@NgModule。
【问题讨论】:
-
你可以参考这个链接。 stackoverflow.com/questions/38888008/…
-
@Karan:没运气,我已经试过了
-
@Karan Patel ,已经提到了这个链接。但是对于 AOT,它不起作用。
-
在此处查看自述文件:https://github.com/laco0416/ng-dynamic
标签: angular angular2-aot ng-modules