Skip object in function with ng-click
I have a template that starts out like:
<li class="list-group-item" ng-repeat="question in question.ChildQuestions" collapse-toggler ng-click="collapseQuestion(this);"> ...
In collapseQuestion
I want to pass an object to be cast to be clicked li
, but when I submit it like collapseQuestion(this);
, I get multiple Object
, but it seems that it doesn't li
(i can't get any class of that object to check what exactly it is) ...
So what's the correct way to pass an object to ng-click
?
source to share
You need to analyze the event.
ng-click="collapseQuestion($event);"
Then in the function use $event.currentTarget
function collapseQuestion($event) {
$event.currentTarget //do something with currentTarget
}
This post can be used: get original element from ng-click
source to share
ng-click="collapseQuestion(question)"
see How to pass an object as a parameter to ng-click inside ng-repeat? AngularJS
source to share