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

?

+3


source to share


2 answers


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

+1


source


ng-click="collapseQuestion(question)"

      



see How to pass an object as a parameter to ng-click inside ng-repeat? AngularJS

0


source







All Articles