【问题标题】:How to add multiple conditions in disabled property of button如何在按钮的禁用属性中添加多个条件
【发布时间】:2020-12-09 14:17:23
【问题描述】:

我想根据两个条件禁用我的按钮。

  1. 表格无效
  2. authenticationType 为真时

我尝试了很多类似下面的东西。

[disabled]="!userForm.form.valid && authenticationType" <br>

[disabled]="(!userForm.form.valid===true && authenticationType===true) ? true : false"

但对我没有用。请帮忙

【问题讨论】:

    标签: javascript angular typescript angular8


    【解决方案1】:

    你写错了语法,userForm本身包含无效和有效的属性。

    你可以简单地使用:

    [disabled]="userForm.invalid && authenticationType"
    

    【讨论】:

      【解决方案2】:

      [disabled]="!userForm.form.valid || authenticationType"

      【讨论】:

        猜你喜欢
        • 2023-02-07
        • 1970-01-01
        • 2019-11-23
        • 2022-12-22
        • 2021-04-15
        • 2017-12-03
        • 2018-05-29
        • 1970-01-01
        • 2015-06-26
        相关资源
        最近更新 更多