Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs多重';或';不起作用的条件_Javascript_Angularjs - Fatal编程技术网

Javascript Angularjs多重';或';不起作用的条件

Javascript Angularjs多重';或';不起作用的条件,javascript,angularjs,Javascript,Angularjs,当我在ng disabled中检查超过2个“或”条件时,它不起作用 下面的代码工作不正常 <button type="button" class="btn btn-primary" ng-click="correctProperty()" ng-disabled="entityPropertyForm.$pristine || propertyCorrected || dropDownChanged">Save</button> 保存 以下两个条件完美地工作 <

当我在ng disabled中检查超过2个“或”条件时,它不起作用

下面的代码工作不正常

 <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>
保存
拯救

为什么我不能检查第三个条件,而只有两个条件工作正常?我尝试了一些其他建议,如“”

我的建议是使用
标记,以确保您获得每个字段的写入值。
<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>
我已将其添加到您的JSFIDLE示例中:


mt0={{mt0}}
mt1={{mt1}}
mt2={{mt2}}
重新分配

为什么不尝试将这两个条件绑定到一个变量,然后针对这1个变量进行测试?这将解决问题。另外,当你说“它不起作用”时,你能更具体一点吗;这是什么意思?你犯了什么错误?如果该1条件不起作用,则很可能是语法或属性本身存在问题。您是否尝试根据测试样本分别检查每个条件?至少可以弄清楚是否所有条件都符合
true
false
我分别尝试了每个条件,效果很好。@SGN然后请创建一个plunkr或一个小提琴来演示不正确的行为。你发布的代码应该可以正常工作。当我说它不工作时,这意味着按钮在不应该的情况下被禁用。虽然有适当的故障排除步骤,但它本身并不是一个答案。这个问题不够清楚,所以我用调试技术来回答。