controllers using as normal function or array notation

后端 未结 2 2039
挽巷
挽巷 2021-01-05 02:19

What is the difference between these 2:

angular.module(\'myapp\' ,[])
.controller(\'MyController\', function($scope){...});

and

<         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-05 02:39

    The second is minification safe.

    Since Angular infers the controller's dependencies from the names of arguments to the controller's constructor function, if you were to minify the JavaScript code for PhoneListCtrl controller, all of its function arguments would be minified as well, and the dependency injector would not be able to identify services correctly.

    Source

提交回复
热议问题