I am trying to overwrite header defaults for POST requests in http header. Even i am providing $httpProvider in the function argument, but still it is throwing error.
Code is -
angular.module('myApp.services', ['ngCookies'])
.service('sharedProperties', function ($cookieStore, $http, $httpProvider) {
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www- form-urlencoded;charset=utf-8';
});
The error is -
Error: [$injector:unpr] Unknown provider: $httpProviderProvider <- $httpProvider <- sharedProperties
$httpProvider is accessible only in config... you should change you code like:
angular.module('myApp.services', ['ngCookies'])
.config(function($httpProvider){
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
})
.service('sharedProperties', function ($cookieStore, $http) {
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With