angularjs - $update PUT method in Angular? -


i couldn't find examples of using $update put method in angular when using ui-router instead of ngroute routing. $update put method possible when using ui-router?

the $update method in example linked in question comments has nothing $routeparams or $stateparams. (in cases) refer parameters present within url.

as example, if declared url in config as: /#/foo/:id/bar , visited url: /#/foo/5/bar?hello=world&verified=1 $routeparams , $stateparams object looks like:

{id: 5, hello: "world", verified: "1"} 

note: in case of $stateparams, think url in config might need declared as: /foo/:id/bar?hello&verified

as $update method , put requests, these related angular-resource module. you'll notice example cited service (factory) declared makes use of $resource service. if take @ docs under returns section you'll see $resource service return:

a resource "class" object methods default set of resource actions optionally extended custom actions. default set contains these actions:

{'get':    {method:'get'},  'save':   {method:'post'},  'query':  {method:'get', isarray:true},  'remove': {method:'delete'},  'delete': {method:'delete'} }; 

it further states:

the actions save, remove , delete available on methods $ prefix.

so $save, $remove, $delete avaiable no $update. why service in example has line:

... 'update': { method: 'put'}, ... 

it's meant extend these default set of actions $update available method on objects , use http put method instead of get/post/delete others.

i sugggest further reading on $routeparams, $stateparams , ngresource distinction between them clear.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -