I am trying to add dynamic headers to a $resource like so:
angular.module('app')
.factory('API', function ($resource, API_URL) {
return {
event: function(userId){
return $resource(API_URL + '/event/:id', {
id: '@id'
}, {
get: {
method: 'GET',
headers: {
'service': 'API',
'userId': userId
}
},
save: {
url: API_URL + '/event/:id/accept',
method: 'PUT',
headers: {
'service': 'API',
'userId': userId
}
}
})
}
};
});
Using this allows me to pass in headers which works fine when using the get.
When I want to save a object this just returns undefined:
var event = new Muse.event('jonro')(object);
Could someone please help explain why I cant use $resource in this way.
Thanks