我在搜索页面中有以下输入字段。
目前,运营商持有“IsEmpty”值。我想禁用ValueToSearch,因为Operator值为Empty。如果运算符不是IsEmpty(例如,equals,not equals),那么我应该显示ValueToSearch。
如果条件不正确,如何禁用。?
<div ng-if="query.field.operatorClass == 'ComparableOrNull' || query.field.operatorClass == 'IntOrNull'" class="ng-scope">
<!-- ngIf: selectedOperator[$index] == translatedIsEmpty -->
<!-- ngIf: selectedOperator[$index] != translatedIsEmpty -->
<input ng-if="selectedOperator[$index] != translatedIsEmpty" blur-integer="" ng-model="query.value" class="form-control ng-valid ng-scope ng-dirty ng-valid-parse ng-touched">
<!-- end ngIf: selectedOperator[$index] != translatedIsEmpty -->
</div>
由于
答案 0 :(得分:0)
您需要使用ngDisabled 和ngInit指令!
看看这个:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app>
Column : <input ng-model="column" /> <br/>
Operator : <input ng-init="operator=''" ng-model="operator" /> <br/>
Value To Search : <input ng-model="valueToSearch" ng-disabled="operator==''" />
</div>
隐藏你可以使用ngIf:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app>
<div ng-init="translatedIsEmpty=''" ng-repeat="op in ['+','','*']">
Column :
<input ng-model="column" />
<br/>Operator :
<input ng-model="op" />
<br/>Value To Search :
<input ng-if="op != translatedIsEmpty"/>
</div>
</div>