AngularJS Select Exampl
by sandipchitale
HTML
<div ng-app ng-controller="MyCtrl">
<h2>Selected Colors: {{selectedColors.length}}</span>
<ul>
<li ng-repeat="sc in selectedColors">{{sc}}
<button ng-click="deleteColor($index)">-</button>
</li>
</ul>
<select ng-model="color" ng-options="c for c in colors"></select><button ng-click="add()">+</button>
</div>
JavaScript
function MyCtrl($scope) {
var colorsDomain = ["red", "blue", "orange", "green", "yellow"];
$scope.selectedColors = [];
$scope.colors = colorsDomain;
$scope.color = colorsDomain[0];
$scope.add = function () {
$scope.selectedColors.push($scope.color);
};
$scope.deleteColor = function (i) {
$scope.selectedColors.splice(i, 1);
};
}