私はアプリケーションに使用するすべてのコンポーネントを保存する設定ファイルとしてサービスを提供しています。これらのコンポーネントはすべて、私のメインコンポーネントからentryComponentsにロードする必要があります。私は、サービスからコンポーネントの配列をメインコンポーネントのデコレータにロードします。私は次のことをしたいの主要コンポーネントでデコレータ内のサービスを角度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.
})
助けてください!