angularjs $resource update using PUT fails when parameter name changes -


i'm missing in understanding or code here...

i've got basic crud app list/add/edit/delete categories, , works fine when define primary key on table "id", when rename database column "categoryid", put url not include key value, , end 404 error unhandled path...

stack:

iis 7.5 w/ slim php restful services

// route excerpt ...           when('/categories',       {templateurl: 'partials/categorylist.html',   controller: categorylistctrl}).           when('/categories/new',   {templateurl: 'partials/categorydetail.html', controller: categorynewctrl}).           when('/categories/:id',   {templateurl: 'partials/categorydetail.html', controller: categoryeditctrl}). ...  angular.module('myservices', ['ngresource'])  .factory('category', function($resource){      return $resource('../api/index.php/categories/:id', {id:'@categoryid'},          { update: {method:'put' } }       );  })     // works when attribute 'id' .factory('category', function($resource){         return $resource('../api/index.php/categories/:id', {id:'@id'},              { update: {method:'put' } }         );     })   // fails 404 when attribute 'categoryid' .factory('category', function($resource){         return $resource('../api/index.php/categories/:id', {id:'@categoryid'},              { update: {method:'put' } }         );     }) 

of course there number of other places in code name changed, effect i'm seeing seems related ngresource.

the first method produces url works...

 categories/1?description=null&name=observation&report=null /api/index.php 

the second produces this...

 categories?categoryid=1&description=null&name=observation&report=null /api/index.php 

with 404 error due malformed path.

is there parameter (or directive or something) required renamed attribute used in url?

i tested put second resource , works expected. way reproduce if issuing instead of put. if open demo , view network tab (chrome/etc) can see put , produce.

http://plnkr.co/edit/ti9kpqdp49pxujjvjivm?p=preview

the produces querystring parameterized data:

get produces:

request url:http://run.plnkr.co/api/index.php/categories?categoryid=123 request method:get 

put produces:

request url:http://run.plnkr.co/api/index.php/categories/123 request method:put 

code:

   var test= $resource('../api/index.php/categories/:id', {id:'@categoryid'},          { update: {method:'put' } }     );       var test2= $resource('../api/index.php/categories/:id', {id:'@categoryid'},          { get: {method:'get' } }     );      test.update({categoryid:123});     test2.get({categoryid:123}); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -