Controllers are callables, and their arguments must be injected with existing/valid/registered dependencies. Angular takes three ways:
If the passed controller (this also applies to providers) is an array, the last item is the controller, and the former items are expected to be strings with the names of dependencies to inject. The names count and the arity must match.
//parameter names are what I want.
c = mymodule.controller('MyController', ['$scope', '$http', function($s, $h) {}]);
Otherwise, if the passed controller has an $inject property, it is expected that such property is an array of strings being the names of the dependencies. The length of the array and the arity must match.
con = function($s, $h) {};
con.$inject = ['$scope', '$http'];
c = mymodule.controller('MyController', conn);
Otherwise, the array of names to inject is taken from the parameter list, so they must be named accordingly.
c = mymodule.controller('MyController', function($scope, $http) {});
//one type, one minification, and you're screwed
You should never expect that the controller works if you don't explicitly set -explicitly- the names of the dependencies to inject. It is a bad practice because:
- The parameter names will change if you minify (and you will -some day- minify your script).
- A typo in your parameter name, and you'll be hours looking for the error.
Suggestion: always use an explicit notation (way 1 or 2).