angular 4 Kendo dialog disable action button

久未见 提交于 2019-12-08 00:31:24

问题


I want disable 'Save' button if 'TotalUnits' < 0 . How can I disable actions 'Save' button?

Main Component:

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 - Dialog:

  @Input() public TotalUnits: number;

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

回答1:


When you want to disable an input you can add the [disabled] attribute binding to the tag you wish to disable.

In your case something along these lines should work:

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

I'm not particularly familiar with Kendo but you can check their documentation for more examples.




回答2:


In AllocationComponent add these lines,

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


来源:https://stackoverflow.com/questions/49866322/angular-4-kendo-dialog-disable-action-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!