
当固定数组工作时?

我想使用这个从路由中提取组件的方法:
function* getRoutesComponents(routes: Routes) {
for (const route of routes) {
if (route.component) {
yield route.component;
if (route.children) {
yield* getRoutesComponents(route.children);
}
}
}
}
@NgModule({
imports: [SharedModule, RouterModule.forChild(ROUTES)],
declarations: getRoutesComponents(ROUTES)
})
export class ProductModule {} 因此,我可以避免在声明属性中遗漏组件声明。声明中缺少组件将导致错误:NG8002: Can't bind to 'ngModel' since it isn't a known property of 'input'
发布于 2020-03-11 16:38:12
要为声明启用runtime population of components,我们需要禁用Angular的AOT。这可以通过将ng serve或ng build的--aot设置为false来完成。

然而,禁用AOT会带来两个主要的不便。首先,我们不能再在对象上使用常量作为键。其次,当AOT被禁用时,尽管fullTemplateTypeCheck被设置为true,Angular仍然会构建项目,即使绑定到ngModel的名称有拼写错误或拼写错误。
https://stackoverflow.com/questions/60618083
复制相似问题