【发布时间】:2018-12-17 23:03:22
【问题描述】:
是否可以声明一个数组并使用它来引导 module.ts 中的多个组件。 我正在尝试这样的事情
export var initialComponents = [];
initialComponents.push(AppComponent);
if(condition) {
initialComponents.push(IchFooterComponent);
}
然后
bootstrap: initialComponents
这给了我以下错误
错误:模块 oa 被引导,但它没有声明“@NgModule.bootstrap”组件,也没有声明“ngDoBootstrap”方法。请定义其中之一。
【问题讨论】:
-
你声明了@ngModule 吗?
@NgModule({ declarations: initialComponents | Array<Type<any> | any[], bootstrap: Array<Type<any> | any[] }) -
是的,我声明了 ng 模块
标签: javascript angular typescript frontend angular6