我想使用带有子组件的 Ng Bootstrap Modal 作为模态体。我不确定我将如何实现这一目标......
export class ParentComponent {
@ViewChild("modal") private engineModal: TemplateRef<any>;
dialog: NgbModalRef | null;
constructor(private modalService: NgbModal) {}
openModal(): void {
this.dialog = this.modalService.open(this.engineModal);
}
cancelModal (): void {
if ( this.dialog ) {
this.dialog.dismiss();
this.dialog = null;
}
}
}
而且,我知道这是错误的,但最终我想做这样的事情,
<ng-template #modal>
<app-child-component></app-child-component>
</ng-template>
子组件有很多输入和输出变量,那么这里最好的方法是什么?