5 ms·
You are completely missing the point of directives. Your proposed alternative strategy of using "only jQuery, Underscore templates and a CommonJS compiler" will
by marknutter 13y ago
You are completely missing the point of directives. Your proposed alternative strategy of using "only jQuery, Underscore templates and a CommonJS compiler" will leave you with DOM manipulation code entangled with your controller logic and a nearly untestable mess. Directives are meant to encapsulate any code that directly deals with manipulating the DOM so that stuff doesn't leak into your model or controller logic.
You of course don't have to throw everything into directives but then you risk making your code less portable and your tests more brittle. Wrapping a jQuery plugin in a directive is so trivial it's not even worth mentioning, and it certainly doesn't result in "enormous amounts of glue code to please AngularJS".
> over-complicated testing procedures
And this is where you showed your hand. You can't have written tests for an angular app because if you had you wouldn't have made such a bizarre statement. Angular's dependency injection combined with the fantastic Karma test runner makes testing an absolute breeze.
- kaeawc 13y ago> so trivial it's not even worth mentioning If it is so trivial then it 'is' worth mentioning. Give an example or reference. Personally I like Angular, but I'm learning and finding articles like the OP's are great to read to have others' perspectives on how to work with it.
- marknutter 13y agoI mean it's not worth mentioning in a disparaging way.
- adamnemecek 13y agoE.g. http://amitgharat.wordpress.com/2013/02/03/an-approach-to-use-jquery-plugins-with-angularjs/ http://amitgharat.wordpress.com/2013/02/03/an-approach-to-us...
- abrkn 13y agoPaste a directive here that shows how AngularJS is not bloated.
- Kiro 13y agoSorry but I personally find testing in Angular very fuzzy. It works great on school examples (test a function that should reverse a string) but in real-world I never know how to apply it or even what good it will do. Where do I start and why is it better because of DI? Also Karma still requires something like Jasmine which means I need to learn two new tools (as well as how testing works in Angular). It is complicated for someone who is not used to testing at all.