首页 新闻 会员 周边 捐助

angular 升级后 NzModalService 打开的对换框内容为空

0
悬赏园豆:30 [已解决问题] 解决于 2025-05-07 11:48

从 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: {},
        });
    });

对话框内容却为空

dudu的主页 dudu | 高人七级 | 园豆:24691
提问于:2025-05-07 11:19
< >
分享
最佳答案
0

需要把 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: {},
        });
    });
dudu | 高人七级 |园豆:24691 | 2025-05-07 11:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册