Maison  >  Questions et réponses  >  le corps du texte

AngularJS Select默认值?

AngularJS Select绑定的是对象:

$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>

现在想给select一个默认值怎么设置呢?

高洛峰高洛峰2870 Il y a quelques jours650

répondre à tous(2)je répondrai

  • 欧阳克

    欧阳克2016-11-12 14:06:46

    répondre
    0
  • 三叔

    三叔2016-11-12 14:06:35

    
    
    $scope.selectedCar = $scope.cars.car01;

    这样就是默认选中第一项

    répondre
    0
  • Annulerrépondre