Reputation: 2735
I am trying to inject $http serivce into app config, but getting "unknown provider $http error".
woi.config(['$routeProvider', '$locationProvider','$http', function($routeProvider, $locationProvider,$http){
$routeProvider
.when("/channels", {
templateUrl: test,
resolve: {
app: function($http){
}
}
})
]});
My question is , is it possible to inject $http serivce in app config ,and if not then what are the other ways to do ajax call before controller and template is called.
Thanks,
Upvotes: 1
Views: 2253
Reputation: 42669
You can directly pass $http
or any dependency into the function, without defining it at config function. The DI framework of Angular would inject dependencies for resolve object functions.
Upvotes: 3