I have a search filter in table and I given ng-model name as selectedGcode for it. I am calling ng-click =viewAccount() inorder to call the function on click. But I am getting $scope.selectedGcode in my controller as undefined.
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;
});
};