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 more advanced logger than just using $log
)
When I reach the debugger line, I've noticed that $http
is undefined unless I include '$http' in the list of dependencies. The AngularJS documentation does not cover this scenario explicitly. Their example of native service injection appears like:
angular.module('myModule', [], function($provide) {
If I am also using one of my own services, would I need to declare $provide
as a dependency? I'm uncertain about when I can expect the automatic injection of $
services and when I must manually declare them.