AngularJS Select default value?
天蓬老师
天蓬老师 2017-05-15 17:07:59
0
2
543

AngularJS Select binds objects:

$scope.cars = {
car01 : {brand : "Ford", model : "Mustang", color : "red"},
car02 : {brand : "Fiat", model : "500", color : "white"},
car03 : {brand : "Volvo", model : "XC90", color : "black"}
};
<select ng-model="selectedCar" ng-options="y.brand for (x, y) in cars"></select>

How to set a default value for select now?

天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(2)
世界只因有你
<select ng-model="selectedCar" ng-options="y.brand for (x, y) in cars>
</select>
$scope.selectedCar = $scope.cars.car01;

This means the first item is selected by default

漂亮男人

<option>--please select--</option>

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template