我有下拉菜單,其中的選項來自使用ng-repeat的數組。它正常工作,正常下拉。但我想用不同的方式。如果選擇了一個選項,則應在其他下拉列表中禁用該選項。我們可以這樣做嗎?如何限制下拉選擇使用角度只有一個值?
<div ng-app="myApp" ng-controller="MyCtrl">
<div ng-repeat="address in addresses">
Billing State:
<select
ng-model="address.state"
ng-options="state.lookupCode as state.description for state in lov_state"></select>
<tt>State selected: {{address.state}}</tt>
</div>
</div>
控制器代碼:
var myApp = angular.module('myApp', []);
myApp.controller('MyCtrl', function($scope) {
$scope.addresses = [
{'state': 'AL'},
{'state': 'CA'},
{'state': 'FL'}
];
$scope.lov_state = [
{'lookupCode': 'AL', 'description': 'Alabama'},
{'lookupCode': 'FL', 'description': 'Florida'},
{'lookupCode': 'CA', 'description': 'California'},
{'lookupCode': 'DE', 'description': 'Delaware'}
];
});
請幫我做到這一點。這是jsfiddle鏈接。
https://jsfiddle.net/santhosh1a32/3vd7hyrq/
這可以幫助你。 http://stackoverflow.com/questions/22005601/how-can-i-disable-to-select-the-particular-option-from-angularjs-dropdown。你可以使用類似的概念。 – chaoticmind