私はangular2で動的にコンポーネントをロードしようとしていますし、それがで出erroringだ:2角度:動的コンポーネントをロードしようとしてき:TypeError例外を:プロパティを読み取ることができません「parentInjector」
例外:エラー:キャッチされない(中約束):TypeError例外:未定義
のプロパティ 'parentInjector' を読み取ることができません、これはコードです:
@Component({
selector: 'Notes5',
template: `<span #extensionAnchor></span>`
})
export class Notes5 extends NotesBase {
constructor(private dynamicComponentLoader:DynamicComponentLoader, private NotesService:NotesService,
protected sliderPanel:Sliderpanel,
protected commBroker:CommBroker) {
this.LoadComponentAsync("src/comps/app2/notes/NoteDynamic", "TestComponent", this.extensionAnchor);
}
@ViewChild('extensionAnchor', {read: ViewContainerRef}) extensionAnchor:ViewContainerRef;
public LoadComponentAsync(componentPath:string, componentName:string, locationAnchor:ViewContainerRef) {
System.import(componentPath)
.then(fileContents => {
console.log(fileContents);
return fileContents[componentName]
})
.then(component => {
this.dynamicComponentLoader.loadNextToLocation(component, locationAnchor)
});
}
}
任意のアイデア?
よろしく
ショーン
「DynamicComponentLoader」は廃止予定です。代わりに 'ComponentResolver'を使うべきです。また、このエラーは、参照されているコンポーネントクラスの注釈プロパティー(おそらく 'TestComponent')を探すためです。クラスには 'TestComponent'もありますか? –
新しいComponentResolverを持つサンプル – born2net
tx David、ありがとう!!!!!! – born2net