Reputation: 355
HTML
<li ng-show="sample($event)" TestLi</li>
Javascript
$scope.sample = function($event){ //$event is undefined
//do something
}
I've only tried passing the html element using ng-click but is there a way to pass it using ng-show?.
Upvotes: 3
Views: 4674
Reputation: 3062
The attribute ng-show, ng-hide and ng-if usually evaluate expression and not function. You can read about it here:
https://docs.angularjs.org/api/ng/directive/ngShow
However, if you really wish to get the target element, you may try writing a very simple directive.
<li ng-show="sample($event)" getTarget> TestLi</li>
app.directive("getTarget", function() {
return {
link: function(scope, element, attrs) {
console.log(element);
}
}
});
Upvotes: 3