by phpnode · 13y ago · 0 comments
<a ng-click="modal.saved=true;dismiss()">...</a>
is any different to <a onClick="thisIsAnAntiPattern()">...</a>
I'm all for declarative code but isn't stuffing javascript in html attributes something we learnt not to do about 10 years ago? Why the resurgence? <a ng-click="modal.saved=true;dismiss()">...</a>
and <a onClick="thisIsAnAntiPattern()">...</a>
and why context / scope matters could be found here: http://www.bennadel.com/blog/2439-My-Experience-With-Angular...Your HTML has to be hooked up to your controller somehow, I personally prefer angular's declarative approach rather than a big messy init method.
That's the case, for me anyway.
As a side point, you can't evaluate arbitrary JavaScript in Angular attributes. Angular parses the attributes and evaluates them as in a JavaScript-like way, but with some exceptions. See http://docs.angularjs.org/guide/expression
More things change, more they remain the same.
PS: I am not saying JS in attributes is a good thing, but just that these things keep happening, for good or worse.
And why?