2017-05-23 33 views
0

我有選擇的標籤在HTML如何DIR-PAGINATE項目傳遞給角功能

<select id="selectTerminalGroups" ng-model="selectedGroup" ng-change="showSelected(x)"> 
    <option dir-paginate="x in serverData | itemsPerPage: serverData.length" value='{{ x.id }}'>{{ x.name }}</option> 
    <input class="getItems" name="Submit" type="submit" value="Renew" ng-click="showSelected(x)"/> 
</select> 

,這裏是我的showSelected(x)功能

$scope.showSelected = function(item) 
    { 
     console.log(item); 
    } 

在角功能我X(「項目」的角)未定義。我想以角度取這個x對象

回答

1

更改showSelected(x)showSelected(selectedGroup)。 ng-modal曲目的當前元素值。

編輯 有一個工作示例嘗試此操作。

var app = angular.module("app",[]); 
 
app.controller("ctrl", function($scope){ 
 

 
$scope.data = [{name:'test1'},{name:'test2'},{name:'test3'}]; 
 
$scope.selectedItem = $scope.data[0]; 
 
$scope.change = function(item) 
 
{ 
 
    console.log(item) 
 
} 
 

 
})
<html> 
 
    <head> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
    </head> 
 
    <body ng-app="app" ng-controller="ctrl" > 
 
    <select ng-model="selectedItem" ng-change="change(selectedItem)" > 
 
    <option ng-repeat="item in data" > {{item.name}} </option> 
 
    <input name="Submit" type="submit" value="Renew" ng-click="change(selectedItem)"> 
 
    </select> 
 
    </body> 
 
</html>

+0

不,它是不確定的太 –

+0

檢查serverData是它填補?並重復觀點? –

+0

雅我有serverdata項目 –