Michael Lewis
Michael Lewis

Reputation: 4302

AngularJS Guide - Dependency Injection - Factory methods

At the bottom of Angular's Dependency Injection guide, I came across this snippet about factory methods, and I'm having a hard time understanding where the "depProvider" and "depService" are being defined:

Here's the snippet:

  angular.module('myModule', []).
  config(['depProvider', function(depProvider){
    ...
  }]).
  factory('serviceId', ['depService', function(depService) {
    ...
  }]).
  directive('directiveName', ['depService', function(depService) {
    ...
  }]).
  filter('filterName', ['depService', function(depService) {
    ...
  }]).
  run(['depService', function(depService) {
    ...
  }]);

Am I correct in that 'depProvider' and 'depService' are injected into these definitions, and would have to be defined elsewhere? Or are these built-in dependencies?

Upvotes: 0

Views: 86

Answers (2)

Michael Benford
Michael Benford

Reputation: 14114

Yes, you're right. That dependencies can be in the same module or in any module declared as a dependency (modules can have dependencies too).

For what it's worth every Angular built-in service starts with a $ so they are easily spotted (e.g. $scope, $http, $timeout etc).

Upvotes: 1

Wottensprels
Wottensprels

Reputation: 3327

I assume that those are fictional modules that should show you how a factory (or anything else) could *dep*end on another service.

They are no built-in modules or anything.

Upvotes: 1

Related Questions