I'm trying to make a POST request to a URL with the following format:
/questions/:questionId:/answers
I have a resource set up (notice the custom save URL):
angular.module('questions').factory('AnswersResource',
['$resource',
function($resource) {
return $resource('questions/:questionId/answers/:answerId', {
answerId: '@_id'
}, {
save: {
method: 'POST',
url: 'questions/:questionId/answers'
}
});
}
]);
With a wrapper:
angular.module('questions').factory('Answers',
['AnswersResource',
function(AnswersResource) {
return {
save: function(answer, questionId) {
AnswersResource.save({questionId: questionId}, answer);
}
}
}
]);
When I make a call to:
Answers.save($scope.answer, '123456');
I get a POST request to the server like this (notice the appended question mark):
POST /questions/123456/answers?
This throws off the routing on my back-end. Does anyone know why this question mark is appearing?
Thanks!