Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass object in function with 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 ?

like image 511
demo Avatar asked Sep 07 '26 19:09

demo


1 Answers

You 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

like image 199
Ashley Medway Avatar answered Sep 10 '26 08:09

Ashley Medway



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!