Based on the following sample, how can I set the $resource
timeout and headers globally? I have a number of $resource
definitions like the following but I’d prefer to not repeat the basic config for each.
angular
.module('myApp.services')
.factory('myServices', myServices);
myServices.$inject = ['$resource'];
function myServices($resource) {
return {
serviceA: $resource('/api/serviceA', {
serviceA_paramA: '@serviceA_valueA',
serviceA_paramB: '@serviceA_valueB'
}, {
'get': {
method: 'GET',
timeout: 120000
}
}, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}),
serviceB: $resource('/api/serviceB', {
serviceB_paramA: '@serviceB_valueA',
serviceB_paramB: '@serviceB_valueB'
}, {
'get': {
method: 'GET',
timeout: 120000
}
}, {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
};
}