[英]Angular 2 Dynamically bootstrap app components
动态引导应用程序组件是否可能取决于元素是否存在。
想要像...那样的东西
export class AppModule {
constructor() {
}
ngDoBootstrap(appRef: ApplicationRef) {
for(let component of components) {
if(document.querySelector(component.selector)){
appRef.bootstrap(component);
}
}
}
}
不,您需要检查自己元素是否在DOM中可用,然后调用platformBrowserDynamic().bootstrapModule(AppModule);
或appRef.bootstrap(component);
或以其他方式跳过调用它。
另见https://github.com/angular/angular/issues/11730#issuecomment-252677321
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.