我无法根据选中的复选框禁用字段,或者不使用Angular.js。我在下面解释我的代码。
<div class="col-md-4">
<div class="form-group">
<label>Status</label>
<select class="form-control" name="status" id="status" ng-model="status" ng-disbaled="!$scope.ochkpancard && !$scope.ochkadhar">
<option value="">Select Status</option>
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label><input id="ochkpancard" type="checkbox" ng-model="ochkpancard" /> Pancard</label>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label><input id="ochkadhar" type="checkbox" ng-model="ochkadhar" /> Aadhar Card</label>
</div>
</div>
我需要在未选中复选框时,选择框将保持禁用状态,当选中复选框时,将启用选择框。
答案 0 :(得分:0)
这是工作代码:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<div class="col-md-4">
<div class="form-group">
<label>Status</label>
<select class="form-control" name="status" id="status" ng-model="status" ng-disabled="!(ochkpancard && ochkadhar)">
<option value="">Select Status</option>
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label><input id="ochkpancard" type="checkbox" ng-model="ochkpancard" /> Pancard</label>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label><input id="ochkadhar" type="checkbox" ng-model="ochkadhar"/> Aadhar Card</label>
</div>
</div>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
});
</script>
</body>
</html>
&#13;