簡體   English   中英

AngularJS多個'OR'條件不起作用

[英]Angularjs multiple 'OR' conditions not working

當我在ng-disabled中檢查超過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>

為什么我不能檢查第三個條件,只有兩個條件可以正常工作? 我嘗試了其他一些建議,例如“ 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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM