Can the HTMLElement be passed to an ng-click function set up on a controller?
Take a look at this example code:
<div ng-controller="Controller">
<ul ng-repeat="item in items">
<li ng-click="handleThisElement($element)" id="{{item.id}}" >{{item.name}}</li>
</ul>
</div>
The Controller:
function ($scope) {
$scope.items = [
{name: 'Bilbo', id='Bilbo'},
{name, 'Frodo', id='Frodo'},
{name: 'Pippin', id='Pippin'},
{name: 'Merry', id='Merry'},
{name: 'Sam', id='Sam'}
];
$scope.handleThisElement = function (element) {
alert(element.id); // should alert (Bilbo || Frodo || Pippin || Merry || Sam)
}
UPDATE:
Just to clarify, I am looking to retrieve the entire element, not just the id from the model.
Using $event.target may not work in certain versions of Internet Explorer.