What are the differences in angular controller not

2020-04-16 01:35发布

问题:

I've have seen a couple of notations to initialize a controller in angular, those are:

app.controller('nameCtrl', function($scope, ... ){})

and

app.controller('nameCtrl', ['$scope','...',function($scope,...){}])

Both work, but I couldn't find anything in the documentation that spot the differences, does it even matter?

回答1:

app.controller('nameCtrl', function($scope, ... ){})

The above won't work with minification, but the below will.

app.controller('nameCtrl', ['$scope','...',function($scope,...){}])