使用的角度版本:v11
我正在尝试使用 ngx-build-plus 将具有延迟加载模块的应用程序作为角度元素集成到另一个应用程序中。我在将元素添加到主应用程序中的组件时遇到了一些困难。当我将它添加到 index.html 时,它会呈现,但当我尝试添加到任何其他 html 文件时显示以下错误。
'cs-root' is not a known element:
1. If 'cs-root' is an Angular component, then verify that it is part of this module.
2. If 'cs-root' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
应用模块文件如下
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
RouterModule,
AppRoutingModule,
CoreModule.forRoot(),
SharedModule.forRoot(),
ToasterModule
],
exports: [AppComponent],
providers: [{ provide: HTTP_INTERCEPTORS, useClass: HttpAuthInterceptor, multi: true },
{ provide: APP_INITIALIZER, useFactory: appInitFactory, deps: [AppInitService], multi: true },
WindowService,
InsightsGuard],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(private injector: Injector) {
const el = createCustomElement(AppComponent, { injector });
customElements.define('cs-root', el);
}
ngDoBootstrap() {
// This method circumvents the natural bootstrapping of the element
}
}
我在这里错过了什么吗?