angular 4 Kendo对话框禁用操作按钮

如果'TotalUnits'<0,我想禁用'保存'按钮 . 如何禁用“保存”按钮?

主要成分:

AllocationDialog(data: any) {
        const dialog: DialogRef = this.component.dialogService.open({
          title: ' Allocations',
          content: AllocationComponent,
          actions: [
            { text: 'Save', primary: true, data },
          ],
          width: 500,
          height: 500
        });
    dialog.result.subscribe((dialogResult) => {
      if (dialogResult instanceof DialogCloseResult) {
        console.log('close');
      } else {
        console.log('action', dialogResult);
      }
    });

    const allocationsInfo = dialog.content.instance;
    allocationsInfo.TotalUnits = data.TotalUnits;
  }

AllocationComponent - 对话框:

@Input() public TotalUnits: number;

 <input kendoTextBox [(ngModel)]="TotalUnits" />

回答(2)

2 years ago

如果要禁用输入,可以将 [disabled] 属性绑定添加到要禁用的标记 .

在你的情况下,这些行的东西应该工作:

<input kendoTextBox [disabled]="TotalUnits < 0" [(ngModel)]="TotalUnits" />

我对剑道并不是特别熟悉,但您可以查看他们的documentation以获取更多示例 .

2 years ago

在AllocationComponent中添加这些行,

<kendo-dialog-actions>
        <button kendoButton [disabled]="TotalUnits < 0">SAVE</button>
</kendo-dialog-actions>