从同一个组件打开时,如何以 2 种不同的方式 CSS 样式 KendoUI-Dialog 标题栏?

How to CSS style KendoUI-Dialog titlebar in 2 different ways when opening from the same Component?

我在设置 KENDO UI 对话框时遇到问题:

我有一个组件,我们称它为 WatComponent。在里面,

如果我通过 DialogService 打开对话框:

const dialogRef = this.dialogService.open({
   title: this.danger ? 'DANGER!' : 'Warning!',
   content: WatDialogComponent
});
const userInfo = dialogRef.content.instance;
userInfo.danger = this.danger;

如何应用两种不同的 CSS 样式(以任何方式)使从同一组件打开时标题栏显示不同的颜色?

我试过了

是否有我缺少的直接解决方案?如果没有,是否有解决方法?

查看 DialogRef API https://www.telerik.com/kendo-angular-ui/components/dialogs/api/DialogRef/ 它包括 ComponentRef 可用于获取主机元素并添加 class:

this.dialog = this.dialogService.open({
    title: 'Warning',
    content: 'Warning'
});
this.dialog.dialog.location.nativeElement.classList.add('warning');

https://plnkr.co/edit/RkW3zHFbmMuQqk4UDYNY?p=preview