从 angular 17 升级到 angular 19 后遇到的问题,下面的代码通过 ng-zorro-antd 的 NzModalService 打开对话框
const title = '批量设置标签';
import('../batch-set-tag/batch-set-tag.component')
.then(({ BatchSetTagComponent }) => {
return this.modalService.create({
nzTitle: title,
nzContent: BatchSetTagComponent,
nzClassName: 'modal-batch-set-tag modal-batch-operation',
nzData: {},
});
});
对话框内容却为空
需要把 ViewContainerRef 传参给 nzViewContainerRef
private readonly _viewContainerRef = inject(ViewContainerRef);
import('../batch-set-tag/batch-set-tag.component')
.then(({ BatchSetTagComponent }) => {
return this.modalService.create({
nzViewContainerRef: this._viewContainerRef,
nzTitle: title,
nzContent: BatchSetTagComponent,
nzClassName: 'modal-batch-set-tag modal-batch-operation',
nzData: {},
});
});