do I have to declare the $http service when requiring other services?
angular.module("ABC.services").service("configService", [
'loggerService', function(logger, $http) {
debugger;
return this.get = function(onError, onSuccess) {
return $http.get("/api/config/").success(function(config) {
logger.debug('loaded config');
return onSuccess(config);
}).error(onError);
};
}
]);
(I have a logger that's more complex than $log)
I find that at the debugger line $http is undefined unless I include
'$http' in the list of dependencies. The docs don't discuss this use case.
Their example of native service injection looks like:
angular.module('myModule', [], function($provide) {
Would I be required to declare $provide as a dependency if I was also
using one of my own services? I'm just really confused about when I can
rely on the automatic injection of $ services and when I have to
explicitly declare them.
No comments:
Post a Comment