Angular: Select value
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.0rc6.min.js"></script>
<div ng-controller="Main" ng-app>
<div>selections = {{selections}}</div>
<div>
<p>Model doesn't get updated when selecting:</p>
<div ng-repeat="selection in selections">
<select ng-model="selections[$index]" ng-options="i.id as i.name for i in items">
<option value=""></option>
</select>
</div>
<button ng-click="reset()">resetting values</button>
</div>
CSS
div {
margin-bottom: 2em;
}
JavaScript
function Main($scope) {
$scope.selections = ["", "id-2", ""];
$scope.reset = function() {
$scope.selections = ["", "", ""];
};
$scope.sample = function() {
$scope.selections = [ "id-1", "id-2", "id-3" ];
}
$scope.items = [{
id: 'id-1',
name: 'Name 1'},
{
id: 'id-2',
name: 'Name 2'},
{
id: 'id-3',
name: 'Name 3'}];
}