Set default-Wert für die dropdownlist mit angularjs?

Ich habe code, der füllt dann dropdownlist-und die javascript-variable, wird das Letzte Element in der Liste. Alles was ich jetzt tun möchte, ist wählen Sie das Letzte Element, das als Standard .Was bin ich ?

<div class="row">
<div>
    <select ng-init="lastItem" ng-model="congressFilter" ng-options="cc.congressLongName for cc in ccList"></select>
</div>
<div class="grid-style" data-ng-grid="userGrid">
</div>

   ccResource.query(function (data) {
    $scope.ccList.length = 0;
    angular.forEach(data, function (ccData) {
        $scope.ccList.push(ccData);
    })

    //Set default value for dropdownlist?
    $scope.lastItem = $scope.ccList[$scope.ccList.length - 1];
});
  • Sollte es nicht ng-model="lastItem"?
InformationsquelleAutor punkouter | 2013-11-11
Schreibe einen Kommentar