4 ms·
Point 3 about "Dependency injection" is often not needed. Just use ng-annotate before minify/uglify, and it will convert the code to the array syntax for you. I
by maaaats 12y ago
Point 3 about "Dependency injection" is often not needed. Just use ng-annotate before minify/uglify, and it will convert the code to the array syntax for you. It handles most of the cases, leaving your code without the ugly array stuff.
It doesn't work for everything, though, so suddenly it blows up. So if you want to be 100% sure your code works as intended do it manually.
- thathonkey 12y agoIt sounds like you talked yourself into doing it the way the author in the article suggests halfway through your post :)
- maaaats 12y agoWell, yeah, deployed a minified angular app yesterday, and ng-annotate handled almost everything except a controller that's initialized a custom way. So it broke. :(
- olov 12y agoThat occasionally happens when you do things in non-standard ways, although ng-annotate has become quite smart lately and can now follow references and more. Did you use the latest version (also feel free to open an issue)? ng-strict-di in AngularJS 1.3 will greatly improve the error messages for these situations.
- sanderjd 12y agoI haven't found anything that doesn't work either automagically or with explicit annotations[0]. [0]: https://github.com/olov/ng-annotate#explicit-annotations https://github.com/olov/ng-annotate#explicit-annotations
- Bahamut 12y agong-annotate works just fine with regular angular controllers/filters/providers/services/etc. definitions, but I would not trust it for special injections found in such stuff such as $state definitions with resolves and maybe $get with the factory returned by a provider.
- olov 12y agoit can certainly not support everything, partly because of limitations imposed by static analysis, buy you may be surprised with what it can handle. Also: For situations where you don't know whether ng-annotate will detect a form or not (assuming you already use ng-annotate for your project), you can use explicitly use /* @ngInject */ or ngInject() to avoid stuttering the array yourself.