modalsのみに依存するライブラリを構築しようとしていCDKます。モーダルはサービスで開かれentryComponent、モーダルでレンダリングするために渡します。
サンプルは次のとおりです: https://stackblitz.com/edit/angular-ofzpks?file=src%2Fapp%2Fmodal.component.ts
モーダル自体では、ファクトリでコンポーネントを作成しています:
const compRef = this.componentFactoryResolver.resolveComponentFactory<any>(this.modalContentComponent);
const componentRef = this.modalContainer.createComponent(compRef);
2 つの問題があります。
componentRef.instance.ngOnInit();手動でトリガーする必要があります- そのコンポーネントにいくつかのデータを渡します:
componentRef.instance.name = this.data.name;しかし、コンポーネントはそれをレンダリングしません