angular - 如何启用和禁用基于选择表单的垫按钮

标签 angular angular-material2

这是我的垫子按钮:

<button class="example-20-width" mat-raised-button disabled>Edit Client</button>

如何根据选择的表单是否为 emtry 来控制它并使其禁用?

这是我的字段表单:

<mat-form-field class="example-full-width">
  <mat-select  placeholder="Select customer">
    <mat-option *ngFor="let food of books.data" 
        [value]="food.company">
      {{food.company}}
    </mat-option>
    <mat-option>
    </mat-option>
  </mat-select>
</mat-form-field>

最佳答案

如果你看Angular Material Demos (button) ,这是 Angular Material 演示的旧版本,有一个执行此操作的按钮。

该演示曾经对应(现已过时)Angular GitHub 页面上的演示,请参阅:github.com - Angular Material - src/demo-app/button .

您可以简单地使用:

<button mat-button [disabled]="isDisabled">

其中 isDisabled 是组件中的 bool 定义。

关于angular - 如何启用和禁用基于选择表单的垫按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49071267/

相关文章:

angular - Angular 路由在nginx docker容器中不起作用

mongodb - Angular 5 + Material 设计 : <mat-select> how to set the default value?

angular - md-form-field 必须包含一个 MdFormFieldControl

Angular Material 2 : use a different font config for headers?

Angular 8惰性路由在父级之前解析有或没有前缀和重定向

javascript - 删除列表项的选项

angular - 在 Angular 中动态创建 templateRefs 并使用 ViewChildren 检索它们

angular - 在运行时以 Angular 关闭动画

css - Angular Material Mat Spinner如何使背景变灰

angular - 使用动态列排序 - Angular Material