【发布时间】:2017-11-01 12:20:43
【问题描述】:
我有一个服务作为配置文件,其中存储了我想在我的应用程序中使用的所有组件。所有这些组件都需要从我的主组件加载到 entryComponents 中。我想将服务中的组件数组加载到主组件的装饰器中。
@Injectable() // This is the service, I want to call getComponents() later on.
export class Configuration {
modules = [
ChartModule
]
components = [
PiechartComponent
]
getModules(): NgModule[] {
return this.modules;
}
getComponents(): Component[] {
return this.components;
}
};
在主要组件中,我想要以下内容:
@Component({
selector: 'dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css'],
entryComponents: Configuration.getComponents() // Here I call the service.
})
请帮忙!
【问题讨论】:
标签: angular