I\'ve seen the documentation of the Angular select directive here: http://docs.angularjs.org/api/ng.directive:select. I can\'t figure how to set the default value. This is
The angular documentation for select* does not answer this question explicitly, but it is there. If you look at the script.js
, you will see this:
function MyCntrl($scope) {
$scope.colors = [
{name:'black', shade:'dark'},
{name:'white', shade:'light'},
{name:'red', shade:'dark'},
{name:'blue', shade:'dark'},
{name:'yellow', shade:'light'}
];
$scope.color = $scope.colors[2]; // Default the color to red
}
This is the html:
This seems to be a more obvious way of defaulting a selected value on an with
ng-options
. Also it will work if you have different label/values.
*
This is from Angular 1.2.7