I want to disable the already selected value from the dropdown using ng-options
AngularJS.
<select name="fruit" ng-model="selectedFruits" ng-options="fruit as fruit.name for fruit in fruits"></select>
<button ng-click="add()">Add</button>
$scope.selectedFruits = undefined;
$scope.finalSelectedFruits = [];
$scope.fruits = [{'name':'banana', 'color':'green'},
{'name':'apple', 'color':'red'},
{'name':'mango', 'color':'yellow'}];
$scope.add = function() {
$scope.model.finalSelectedFruits.push($scope.selectedFruits);
};
Please look at the following image
You can see mango
is already selected. How can disable it in the new dropdown based on the $scope.selectedFruits
.
I don't want to do this within <options></options>