Reason for using array notation when defining AngularJS Controller

后端 未结 4 1617
感情败类
感情败类 2020-11-29 02:15

Apologies if this question sounds too obvious.

I\'ve recently starting exploring and learning AngularJS. I\'ve gone through some good tutorials -

  • Off
4条回答
  •  春和景丽
    2020-11-29 02:45

    The difference is that when the second is minified, the parameter name will be minified and angular will no longer be able to inspect the arguments to figure out which dependencies to inject. The array syntax with the dependency in a string means that it is minification safe.

    There is a library called ng-annotate which will change the second example into the first example so that the code is again minification safe.

提交回复
热议问题