admin管理员组文章数量:1336094
I have template which starts like :
<li class="list-group-item" ng-repeat="question in question.ChildQuestions" collapse-toggler ng-click="collapseQuestion(this);"> ...
In collapseQuestion
i want to pass object that will be reffered to clicked li
, but when i send it like collapseQuestion(this);
i get some Object
but it seems like it isn't li
(i can't get any class of that object to check what exactly it is).
So what is correct way to pass object in ng-click
?
I have template which starts like :
<li class="list-group-item" ng-repeat="question in question.ChildQuestions" collapse-toggler ng-click="collapseQuestion(this);"> ...
In collapseQuestion
i want to pass object that will be reffered to clicked li
, but when i send it like collapseQuestion(this);
i get some Object
but it seems like it isn't li
(i can't get any class of that object to check what exactly it is).
So what is correct way to pass object in ng-click
?
2 Answers
Reset to default 1You need to parse the event itself.
ng-click="collapseQuestion($event);"
Then in the function use $event.currentTarget
function collapseQuestion($event) {
$event.currentTarget //do something with currentTarget
}
This post maybe of use: get original element from ng-click
ng-click="collapseQuestion(question)"
see How I pass an object as a parameter in a ng-click within a ng-repeat? AngularJS
本文标签: javascriptPass object in function with ngclickStack Overflow
版权声明:本文标题:javascript - Pass object in function with ng-click - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742392708a2466305.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论