0

次にドロップダウンリストにデータを入力するコードと、リストの最後の項目を取得するjavascript変数があります。今私がしたいのは、その最後のアイテムをデフォルトとして選択することだけです.何が欠けていますか?

<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];
});
4

2 に答える 2