【发布时间】:2017-01-15 00:46:02
【问题描述】:
我在表中有一个搜索过滤器,我将 ng-model 名称指定为 selectedGcode。我正在调用 ng-click =viewAccount() 以便在单击时调用该函数。但是我的控制器中的 $scope.selectedGcode 是未定义的。
HTML:
<table class="table table-striped">
<thead>
<tr class="myheading">
<th class="col-sm-2"> Code
</th>
<th class="col-sm-2">Name
</th>
</tr>
<tr>
<th class="col-sm-2" >
<input type="text" class="form-control" ng-model="selectedGcode" placeholder="Search" ng-click="viewAccount()" /></th>
<th class="col-sm-2" >
<input type="text" class="form-control" /></th>
<tr>
<tbody>
<tr data-ng-repeat="data in tableData">
<td class ="stylethecontent" >{{ data.groupzcode}}</td>
<td class ="stylethecontent" >{{data.groupzname}}</td>
</tr>
</tbody>
</table>
JS:
$scope.viewAccount = function(){
var json = {
"json": {
"request": {
"servicetype": "6",
"functiontype": "6014",
"session_id": $rootScope.currentSession,
"data": {
"shortname": $scope.selectShortName,
"groupzcode":$scope.selectedGcode
}
}
}
};
UserService.viewListAccount(json).then(function(response) {
console.log(json);
if (response.json.response.statuscode == 0 && response.json.response.statusmessage == 'Success')
$scope.tableData = response.json.response.data;
});
};
【问题讨论】:
-
我没有找到你在控制器中使用 selectedGcode 的任何地方
-
您好,请签入请求。几分钟前编辑过。