I am trying to make one Service (SecondService) a dependency of another (FirstService), where the result from one is going to joined with portions of another.
Disclaimer: I have about 8-10 hours of total AngularJS experience.
angular.module('app') | |
.service('FirstService', ['$q', 'SecondService', function ($q, SecondService) { | |
'use strict'; | |
var deferred = $q.defer(), | |
model; | |
model = { | |
// .. | |
// use SecondService here | |
}; | |
deferred.resolve(model); | |
return deferred.promise; | |
}]); |
angular.module('app') | |
.service('SecondService', ['$q', function ($q) { | |
'use strict'; | |
var deferred = $q.defer(), | |
model; | |
model = { | |
// .. | |
}; | |
deferred.resolve(model); | |
return deferred.promise; | |
}]); |
Based on this, I think what you have there should work? http://docs.angularjs.org/api/AUTO.$provide#methods_service
I must be missing something else then.
I don't know if i understand your need correctly but, if you need to use combine results in a new promise you could just do that : http://plnkr.co/edit/9MRNBZMPJgLFnJP1PQIm?p=preview
Let me know if it answer your question
from http://docs.angularjs.org/guide/dev_guide.services.managing_dependencies