Pass $event with angularjs expression but get undefined value

Home / Uncategorized / Pass $event with angularjs expression but get undefined value

Question:
I’m trying to get where the directives are but got undefined value

HTML code:{{test($event)}}
My controller function:$scope.test = function(e) { console.log(e); };
// return e = undefined
Can I get the target, which call test function in this case?

Thanks!


Answer:
$event property is only available when the expression is used in ‘action’ directives such as ng-click or ng-enter

A quick google search can give you an explanation.

Edit

To add on, double curly braces {{}} generates markup with the evaluated expression provided. So no DOM event are utilized
Read more

Leave a Reply

Your email address will not be published. Required fields are marked *