Javascript 如何在angularjs中重置禁用值
我有两个选择选项框。基于第一个选择选项,第二个选择选项被禁用。假设我在选择第二个选择框,选择框的值就是设置该框。之后我要选择第一个选择框。第二个选择框值被禁用。但不重置第二个选择框值 代码:Javascript 如何在angularjs中重置禁用值,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我有两个选择选项框。基于第一个选择选项,第二个选择选项被禁用。假设我在选择第二个选择框,选择框的值就是设置该框。之后我要选择第一个选择框。第二个选择框值被禁用。但不重置第二个选择框值 代码: <label class="item item-select"> <span class="input-label">Purchase Type </span> <select name="requiredType" ng-model="bid.r
<label class="item item-select">
<span class="input-label">Purchase Type </span>
<select name="requiredType" ng-model="bid.requiredType" required>
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
</label>
<label class="item item-select">
<span class="input-label">Purchase Unit</span>
<select name="purchaseUnitType" class="form-control"
ng-model="bid.purchaseUnitType"
ng-disabled="bid.requiredType=='Full'"
x-ng-change="checkUnitType(bid.purchaseUnitType)" required="required">
<option disabled="" value="">Select Purchase Unit</option>
<option>Kg</option>
<option>Quintal</option>
<option>Ton</option>
</select>
</label>
采购类型
选择采购类型
部分的
满满的
采购单位
选择采购单位
公斤
五分之一
吨
您可以调用ng change
函数重置第二个过滤器的值
JS:
$scope.reset=function(){
$scope.bid.purchaseUnitType="";
}
<select name="requiredType" ng-model="bid.requiredType" required ng-change="reset()">
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
HTML:
$scope.reset=function(){
$scope.bid.purchaseUnitType="";
}
<select name="requiredType" ng-model="bid.requiredType" required ng-change="reset()">
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
选择采购类型
部分的
满满的
工作JSFIDLE:您可以调用
ng change
函数来重置第二个过滤器的值
$scope.reset=function(){
$scope.bid.purchaseUnitType="";
}
<select name="requiredType" ng-model="bid.requiredType" required ng-change="reset()">
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
JS:
$scope.reset=function(){
$scope.bid.purchaseUnitType="";
}
<select name="requiredType" ng-model="bid.requiredType" required ng-change="reset()">
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
HTML:
$scope.reset=function(){
$scope.bid.purchaseUnitType="";
}
<select name="requiredType" ng-model="bid.requiredType" required ng-change="reset()">
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
选择采购类型
部分的
满满的
工作JSFIDLE:您只需在第一个选择框上关联一个
ng更改
,以便在第一个选择框中的选项被更改或选中时,第二个选择框选项被重置。对于禁用,相同的代码可以工作
$scope.reset=function(){
$scope.bid.purchaseUnitType="";
}
<select name="requiredType" ng-model="bid.requiredType" required ng-change="reset()">
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
HTML
请注意,我刚刚重置了函数
changeFirstSelectBox()
中第二个选择框的值。为了简单和进一步的解决方法,这里是到的链接 您只需在第一个选择框上关联一个ng更改
,以便在第一个选择框中的选项被更改或选中时,第二个选择框选项被重置。对于禁用,相同的代码可以工作
HTML
请注意,我刚刚重置了函数
changeFirstSelectBox()
中第二个选择框的值。为了简单和进一步的解决方法,这里是到的链接 如果需要重置第二个下拉选择值,则需要在第一个下拉列表中添加一个
更新的HTML:
<label class="item item-select">
<span class="input-label">Purchase Type </span>
<select name="requiredType" ng-model="bid.requiredType" required ng-change="vm.onRequiredTypeChanged()">
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
</label>
如果需要重置第二个下拉列表中的选定值,则需要在第一个下拉列表中添加一个 更新的HTML:
<label class="item item-select">
<span class="input-label">Purchase Type </span>
<select name="requiredType" ng-model="bid.requiredType" required ng-change="vm.onRequiredTypeChanged()">
<option disabled="" value="">Select Purchase Type</option>
<option>Partial</option>
<option>Full</option>
</select>
</label>