我正在实现一个由几个模块组成的Angular应用程序: -应用模块 -共享模块 -核心模块 -不同的客户模块
该解决方案是高度动态的。 DynamicComponentLoader应该创建我的组件。我遵循此处描述的方法:https://angular.io/guide/dynamic-component-loader
问题:问题是,我不确定如何注册我的所有组件,因为它们位于不同的模块中。
SharedModule:
ndk {
abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
}
DynamicComponentService
...
/**
* Implements "forRoot(): ModuleWithProviders"
* to register all Services in the Root Injector.
*/
@NgModule({
imports: imports,
providers: [DynamicComponentService],
declarations: declarations,
exports: componentsToExport,
entryComponents: componentsDynamic,
})
export class SharedModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SharedModule,
providers: providers
};
}
DynamicComponentBuilderComponent
export class DynamicComponentService {
private dynamicComponents: DynamicComponentDescriptor[] = [];
constructor() { }
public addComponents(components: DynamicComponentDescriptor[]) {
this.dynamicComponents = this.dynamicComponents.concat(components);
}
...
}