2
我有一個服務作爲配置文件,用於存儲我想要在我的應用程序中使用的所有組件。所有這些組件都需要從我的主要組件加載到entryComponents中。我想將服務中的組件數組加載到主要組件的裝飾器中。在Angular 4中使用裝飾器中的服務
@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.
})
請幫幫忙!