声明:
这里的nzContent是NG-ZORRO of angular 的Modal对话框里的内容
修改下图中,红框标注的位置。官网是用反引符引入的HTML代码,但是,我们要是使用复杂的样式呢?
1、绑定简单的数据
// name = 小明
<b style="color: red;">${
name}</b>
2、绑定复杂的数据
1、在HTML页面写结构
2、在ts里写逻辑
3、绑定到nzContent里
代码:
// 引入ViewChild
import {
ViewChild, TemplateRef, ChangeDetectorRef } from '@angular/core';
// 拿到dom节点
@ViewChild('tplContent', {
static: false }) tplContent!: any;
// 使用节点 this.tplContent
this.modal.confirm({
nzTitle: '您确定要删除此项吗?',
nzContent: this.tplContent,
nzOkText: '确定',
nzOkType: 'danger',
nzWidth: 600,
nzOnOk: () => {
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
});
<ng-template #tplContent