Is it possible to inject $q in the config section of my module? Below is my sample config section.
.config([\'$q\', function ($q) {
var func = function (
You can use angular.injectorto load $http
and $q
, and probably other services in your config block:
angular.module('myApp').config(function () {
var injector = angular.injector(['ng']),
http = injector.get('$http'),
q = injector.get('$q');
});
It is possible for me (when routing configure):
resolve: {
simpleStringParam: ["$q", "$timeout", function($q, $timeout){
var deferred = $q.defer();
$timeout(function(){
deferred.resolve("Allo!");
},8000);
return deferred.promise;
}]
}
Correct--you can't inject $http or $q from a config function. They are not available yet (they're also being configured!).