CaryLandholt / gulp-ng-classify

Convert CoffeeScript classes to AngularJS modules with ng-classify
MIT License
15 stars 4 forks source link

Use $inject to manually identify your dependencies for Angular components #10

Closed dlinx closed 9 years ago

dlinx commented 9 years ago

According to this documentation, for injection, you should use $inject instead passing array of dependencies and controller method.

ng-classify created this script instead of this.

CaryLandholt commented 9 years ago

Hi @dlinx,

John Papa's style guide, which is terrific, refers to best practices during development. ng-classify is the tool you've chosen (thanks) to use during development.

Using ng-classify you get minification-safe code and avoid long dependency lists, since you only need to including them once in the constructor.

The following, taken from John Papa's style guide, are all achieved with ng-classify.

Why?: This technique mirrors the technique used by ng-annotate, which I recommend for automating the creation of minification safe dependencies. If ng-annotate detects injection has already been made, it will not duplicate it.

Why?: This safeguards your dependencies from being vulnerable to minification issues when parameters may be mangled. For example, common and dataservice may become a or b and not be found by Angular.

Why?: Avoid creating in-line dependencies as long lists can be difficult to read in the array. Also it can be confusing that the array is a series of strings while the last item is the component's function.

Hope this clarifies things.

CaryLandholt commented 9 years ago

Feel free to re-open if needed.