angular onclick传值
angular onclick pass values
这是我的 AngularJS ng-click 功能,它不起作用。我需要通过这个函数得到branch.id
:
<tr data-id="0" ng-model="row1" ng-repeat="branch in details | filter:branchsearch | limitTo:10" style="border-bottom:1px solid ;">
<td style="display: none">{{branch.branch_id}}</td>
<td ng-click="getid(branch.branch_id)" class="tablerow"> {{branch.name}}</td>
<td ng-click="getid(branch.branch_id)" class="tablerow"> {{branch.code}}</td>
<td ng-click="getid(branch.branch_id)" class="tablerow"> {{branch.t_name}}</td>
<td ng-click="getid(branch.branch_id)" class="tablerow"> {{branch.city}}</td>
</tr>
还有我的 Angular 函数,它不起作用:
<!-- begin snippet: js hide: false console: true babel: false -->
var adminmodule = angular.module("adminmodule",[]);
// Branch Controller
adminmodule.controller("branchcontroller",['$scope','$http','$filter', function ($scope, $http,$filter) {
branchinfo();
function branchinfo(){
// Sending request to branchinfo.php files
$scope.currentPage = 0;
$scope.pageSize = 10;
$http.post('http://localhost/sms1/adminAsset/script/branchinfo.php').success(function(data){
// Stored the returned data into scope
$scope.details = data;
});
}
$scope.getid=function (id) {
alert(id+'haris Done');
}
$scope.numberOfPages=function(){
return Math.ceil($scope.getData().length/$scope.pageSize);
}
}]);
首先,为什么 post 请求 'get' details
数据没有任何负载?然后考虑您只需要调试以确保从服务中正确获取详细信息数据,为什么要在 tr 上使用 ng-model? (这不是输入字段)。这是一个简单的 plunk,它演示了你需要什么:
这是我的 AngularJS ng-click 功能,它不起作用。我需要通过这个函数得到branch.id
:
<tr data-id="0" ng-model="row1" ng-repeat="branch in details | filter:branchsearch | limitTo:10" style="border-bottom:1px solid ;">
<td style="display: none">{{branch.branch_id}}</td>
<td ng-click="getid(branch.branch_id)" class="tablerow"> {{branch.name}}</td>
<td ng-click="getid(branch.branch_id)" class="tablerow"> {{branch.code}}</td>
<td ng-click="getid(branch.branch_id)" class="tablerow"> {{branch.t_name}}</td>
<td ng-click="getid(branch.branch_id)" class="tablerow"> {{branch.city}}</td>
</tr>
还有我的 Angular 函数,它不起作用:
<!-- begin snippet: js hide: false console: true babel: false -->
var adminmodule = angular.module("adminmodule",[]);
// Branch Controller
adminmodule.controller("branchcontroller",['$scope','$http','$filter', function ($scope, $http,$filter) {
branchinfo();
function branchinfo(){
// Sending request to branchinfo.php files
$scope.currentPage = 0;
$scope.pageSize = 10;
$http.post('http://localhost/sms1/adminAsset/script/branchinfo.php').success(function(data){
// Stored the returned data into scope
$scope.details = data;
});
}
$scope.getid=function (id) {
alert(id+'haris Done');
}
$scope.numberOfPages=function(){
return Math.ceil($scope.getData().length/$scope.pageSize);
}
}]);
首先,为什么 post 请求 'get' details
数据没有任何负载?然后考虑您只需要调试以确保从服务中正确获取详细信息数据,为什么要在 tr 上使用 ng-model? (这不是输入字段)。这是一个简单的 plunk,它演示了你需要什么: