我在html
中选择了标签<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(角度中的'item')未定义。我想以角度
取这个x对象答案 0 :(得分:0)
将showSelected(x)
更改为showSelected(selectedGroup)
。 ng-modal track的当前元素值..
修改强> 有一个工作的例子试试这个。
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>