Skip to content Skip to sidebar Skip to footer

Angularjs - Module Config Function

In this example: angular.module('myModule', [], function($provide) { $provide.factory('serviceId', function() { var shinyNewServiceInstance; //factory function body that

Solution 1:

The third "config function" parameter to the angular.module function is the same as calling module('myModule', []).config(). You should use that syntax if you want to pass dependencies.

angular.module('myModule', []).config(['$provide', function ($provide) {
  $provide.factory('serviceId', function () {
    var shinyNewServiceInstance;
    //factory function body that constructs shinyNewServiceInstance
    return shinyNewServiceInstance;
  });
}]);

Post a Comment for "Angularjs - Module Config Function"