angularjs - ng-resource url parameter does not work -


$resource not correctly passing along url parameter when making put request, via custom action.

this service creating resource.

.factory('cartitemsservice', ['$resource', function($resource) {     return $resource('/api/cart/:cartid/items/', {format: 'json'}, {         get: {method: 'get', isarray: true},         update: {method: 'put', isarray: true},     }); }]) 

in controller i'm trying update list of items this. note $scope.cart.id exists , correct (in case 1)

$scope.cartitems = cartitemsservice.update({cartid: $scope.cart.id}); 

however request url is: /api/cart/items/ i'm expecting /api/cart/1/items/. works fine if .get({cartid: <some_id>}) doesn't seem work update.

edit: angular version 1.1.5

in end due request headers setting before making request.

i attempting set put headers such:

$http.defaults.headers.put['x-csrftoken'] = $cookies.csrftoken; 

this caused request url incorrectly formatted.

changed set post header instead, , worked.

$http.defaults.headers.post['x-csrftoken'] = $cookies.csrftoken; 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -