无法使用ng-click将ng-repeat对象传递给函数? [英] Unable to pass ng-repeat object to function using ng-click?

查看:76
本文介绍了无法使用ng-click将ng-repeat对象传递给函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< table class =table> 
< thead>
< tr>< th> pcat< / th>< th> psub< / th>< th> ocas< / th>< th> metal< / th>< th>编辑< /第>< / TR>
< / thead>
< tbody>
< tr ng-repeat =a1 in co>
< td> {{a1.pcat}}< / td>< td> {{a1.psub}}< / td>< td> {{a1.ocas}}< / td>< td> {{a1.metal}}< / td>< td>< input type =hidden/>< input type =buttonid =b1value =编辑ng-click = edit(a1)/>< / td>< / tr>
< / tbody>
< / table>





 $ scope.edit = function(a1){
alert(a1.data);
$ scope.da = a1.data;
};





我的尝试:



i使用ng-init但没有工作

解决方案

scope.edit = function(a1){
alert(a1.data) ;


scope.da = a1.data;
};





我的尝试:



i使用ng-init但没有工作


参考此检查更正,

警报( a1.data ); 
//没有包含数据的属性,你必须使用对象中的任何一个属性(pcat,psub,ocas,metal)



警报(a1.pcat); 

  <table  class="table">
            <thead>
                <tr><th>pcat</th><th>psub</th><th>ocas</th><th>metal</th><th>Edit</th></tr>
            </thead>
            <tbody>
<tr ng-repeat="a1 in co">
<td>{{a1.pcat}}</td><td>{{a1.psub}}</td><td>{{a1.ocas}}</td><td>{{a1.metal}}</td><td><input type="hidden"/><input type="button" id="b1" value="Edit" ng-click=edit(a1) /></td></tr>
            </tbody>
        </table> 



$scope.edit = function (a1) {
        alert(a1.data);
        $scope.da = a1.data;
    };



What I have tried:

i used ng-init but didn't worked

解决方案

scope.edit = function (a1) { alert(a1.data);


scope.da = a1.data; };



What I have tried:

i used ng-init but didn't worked


refer this check the corrections,

 alert(a1.data); 
// there is no property with data, you will have to use any one of the properties (pcat,psub,ocas,metal) in the object  


alert(a1.pcat);


这篇关于无法使用ng-click将ng-repeat对象传递给函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆