I have a problem with setting the selected item in angular\'s select directive. I don\'t know if this is a bug or a conscious design from the designers of angular. It sure makes
It is as simple as this
Then inside you controller:
// all items
$scope.items = [{name: 'a'}, {name: 'b'}, {name: 'c'}];
// set the active one
$scope.item = {name: 'b'};
// or just
$scope.item = $scope.items[1]
Check out the http://docs.angularjs.org/api/ng.directive:select From there:
trackexpr: Used when working with an array of objects. The result of this expression will be used to identify the objects in the array. The trackexpr will most likely refer to the value variable (e.g. value.propertyName).
The rest is just assigning a value to the $scope.item
variable and angular will figure out which element should be set as active by checking the item's name
property.