Difference in controller declaration in AngularJS
问题 I have seen controller being declared in two ways as below. But what diff does this make? appmodule.controller('Actrl',['$scope',function($scope) {}]); appmodule.controller('Actrl',function($scope) {}); But, most of the times, the 1st doesn't work. Why? 回答1: Both the syntax are same but the first one is preferred (there is a typo, see below description) if you are minifying your code. Angular resolves the dependency based on the name so when you write appmodule.controller('Actrl',function(