Exploring the concepts in this AngularJS example:
angular.module('myModule', [], function($provide) {
$provide.factory('serviceId', function() {
var shinyNewServiceInstance;
//the factory function creates shinyNewServiceInstance
return shinyNewServiceInstance;
});
});
We are passing a function to angular.module()
that includes the $provide
argument.
- If we minify this code, could it potentially break? Replacing
$provide
with another name (like$zprovide
) results in an error finding the provider. - Attempts to modify the syntax like below were unsuccessful:
['$provide'], function($zprovide){}
angular.module('myModule', ['$provide'], function($zprovide) {
$zprovide.factory('serviceId', function() {
var shinyNewServiceInstance;
//factory function body constructing shinyNewServiceInstance
return shinyNewServiceInstance;
});
});
['$provide', function($zprovide){}]
angular.module('myModule', ['$provide', function($zprovide) {
$zprovide.factory('serviceId', function() {
var shinyNewServiceInstance;
//factory function body creating shinyNewServiceInstance
return shinyNewServiceInstance;
});
}]);
It seems that the dependency injection system used for the angular.module()
function behaves differently from other services. The lack of documentation further complicates understanding this behavior.