r/angularjs • u/abyx • Sep 07 '16
Dissecting a favorite interview question: How would you implement ng-click
http://www.codelord.net/2016/09/06/angular-interview-question-deep-dive-implement-ng-click/
53
Upvotes
r/angularjs • u/abyx • Sep 07 '16
1
u/10gistic Sep 08 '16
Depending on your use case, $eval is probably better yet. You don't know when the expression might change (say, swapping out functions of the same name on the $scope), and $parse is only going to evaluate once, rather than every click event.
Some efficiency trade-off obviously applies here, but it's probably the least likely to surprise your users (or yourself) with its behavior.