Angularjs 多个“OR”条件不起作用

Angularjs multiple 'OR' conditions not working

本文关键字:条件 不起作用 OR 多个 Angularjs      更新时间:2023-09-26

当我在 ng 禁用中检查超过 2 个"OR"条件时,它不起作用。

下面的代码无法正常工作

 <button type="button" class="btn btn-primary" ng-click="correctProperty()" ng-disabled="entityPropertyForm.$pristine || propertyCorrected || dropDownChanged">Save</button>

以下两个条件非常有效。

<button type="button" class="btn btn-primary" ng-click="correctProperty()" ng-disabled="propertyCorrected || dropDownChanged">Save</button>
<button type="button" class="btn btn-primary" ng-click="correctProperty()" ng-disabled="entityPropertyForm.$pristine || propertyCorrected">Save</button>

为什么我无法检查第 3 个条件,只有 2 个条件完美运行?我尝试了一些其他建议,例如"http://jsfiddle.net/8bc24nau/1/"

我的建议是使用 <pre> 标签以确保您获得每个字段的写入值。我已将其添加到您的 jsfiddle 示例中:

<div ng-app>
    <input type="checkbox" ng-model="mt0">
    <input type="checkbox" ng-model="mt1">
    <input type="checkbox" ng-model="mt2">
    <pre>mt0={{mt0}}</pre>
    <pre>mt1={{mt1}}</pre>
    <pre>mt2={{mt2}}</pre>
    <button ng-disabled="(mt0||mt1||mt2)">Reassign</button>
</div>