Here's a scenario where you have a plain old JavaScript (non-Angular) function that is called when an element is clicked:
<span id="foo1" onclick="clicked(this)">...</span>
In this case, the argument passed to clicked()
is the span
object with the id of foo1
.
Now, let's say you want to convert this code to AngularJS. You might try passing the same this
object:
<span id="foo2" ng-click="clicked(this)">...</span>
However, in this scenario, the argument passed to clicked()
is an object that doesn't seem to be related to the span
object.
So, I have a couple of questions:
What exactly is the value of
this
when it's passed to a function viang-click
?How can we easily retrieve the clicked object within the function or pass it as an argument to the function?