角度onclick传递值

时间:2017-07-07 20:12:21

标签: angularjs function angularjs-ng-click

这是我的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">&nbsp;&nbsp;&nbsp;{{branch.name}}</td>
                        <td ng-click="getid(branch.branch_id)" class="tablerow">&nbsp;&nbsp;&nbsp;{{branch.code}}</td>
                        <td ng-click="getid(branch.branch_id)" class="tablerow">&nbsp;&nbsp;&nbsp;{{branch.t_name}}</td>
                        <td ng-click="getid(branch.branch_id)" class="tablerow">&nbsp;&nbsp;&nbsp;{{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);
        }


    }]);

1 个答案:

答案 0 :(得分:0)

首先,为什么没有任何有效负载的帖子请求“获取”details数据?然后考虑你需要调试什么来确保你从服务中正确地获取细节数据,为什么你在tr上使用ng-model? (这不是输入字段)。这是一个简单的插件,展示了你的需求:

https://plnkr.co/edit/JLYJNhs4hIBp10WVaIYM?p=preview