Kendo UI 对话框服务更改标题颜色

KendoUI dialog service change title color

使用 kendo 对话框服务时,是否可以更改对话框 window 的颜色?

目前它默认为红色,但我需要自定义 window 以根据传递的内容显示不同的颜色。

我尝试使用 kendo-dialog 作为我的模板,但它没有显示操作按钮。

<kendo-dialog title="{{title}}" (close)="Cancel()" [ngClass]="yellow">
</kendo-dialog>

我刚才问过自己同样的问题,并在这个 post 中找到了一个解决方案:Kendo UI angular DialogService - 更改标题栏背景颜色

我会在这里复制我的答案: 我为此制定了解决方案。它有效,但一点也不优雅。

这是演示代码的插件 link: http://plnkr.co/edit/MGw4Wt95v9XHp9YAdoMt?p=preview

服务中的相关代码如下:

const dialog: DialogRef = this.dialogService.open({
  actions: message.actions,
  content: MessageComponent,
  title:   message.title
});

const messageComponent = dialog.content.instance;
messageComponent.message = message;

//I get the dialog element and use jQuery to add classes to override styles.
//Let's say I had the error class as well.
const element = dialog.dialog.location.nativeElement;
$( element ).addClass( 'kendo-override ' + message.classes );

return dialog.result;

和 scss:

$error: #c13;
$success: #0c5;

.kendo-override {

  &.error {
    kendo-dialog-titlebar {
      background-color: $error;
    }
  }

  &.success {
    kendo-dialog-titlebar {
      background-color: $success;
    }
  }
}