3 ms·
> onclick="mutateGlobalStateAndPerformIO()" What's wrong with that? Other than scoping problems (which Angular solves), this is far more in line with classic v
by daigoba66 14y ago
> onclick="mutateGlobalStateAndPerformIO()"
What's wrong with that? Other than scoping problems (which Angular solves), this is far more in line with classic view-controller than anything else.
- xaritas 14y agoNothing, but some feel rather strongly averse to it, and plainly view this as Angular's self-evident fatal flaw. As I said I do not subscribe to this line of thinking. My allusion to the horror and barbarism of the pre-JS MVC was merely a jape.
- MatthewPhillips 14y agoWhat happens when you want to add a second, unrelated, thing? Just stick it on the end in the onclick? Create a new function called doTwoThings()? This is one of the reasons I prefer using an observer pattern over MVC.
- aidos 14y agoThat doesn't really happen though - also, Ng-click is a specific directive you can choose not to use. A more general argument is that any behaviour specified in markup is bad. I'd counter that by saying that it's already there in HTML. Input boxes for example have behaviour intrinsic to their being. So angular let's you create a (for example) richtext tag. You attach behaviour to that tag, say on click. In the HTML it's as clean as <richtext>. Within the directive you can make it behave as you please. I think that people see the shortcut directives used in angular (eg Ng-click) and the purists shout "unclean"! The reality is that You can do things a slightly longer way and end up with something thy looks a lot like the observer pattern.
- Zelphyr 14y agoIf I recall, its more efficient to attach the handler in JS than in an onclick attribute.
- ganarajpr 14y agosource for this please?