Considering the injection of dependencies in AngularJS, there are a few ways to do it. The modes as far as I know are:
Form 1:
angular
.module('meuModulo', [])
.controller('MeuController', function(dependencia)) {
//...
});
Form 2:
angular
.module('meuModulo', [])
.controller('MeuController', ['dependencia', function(dependencia)) {
//...
}]);
Form 3:
angular
.module('meuModulo', [])
.controller('MeuController', MeuController);
MeuController.$inject = ['dependencia'];
function MeuController(dependencia)) {
//...
}
I used as an example controller
but you can use it for factory
, directive
, filter
, etc.
My questions about this are: What are the real differences between ways to inject dependencies? What is the indication for each case? Do you have other ways to do them?