This is the example at : http://docs.angularjs.org/api/ngResource/service/$resource all the way at the bottom.
// First get a note object from the factory
var note = Notes.get({ id:$routeParams.id });
$id = note.id;
// Now call update passing in the ID first then the object you are updating
Notes.update({ id:$id }, note);
I'm not too sure what this part is doing though. Currently i use get like so:
MyService.get(function(data){//do stuff with data});
and after making my updates I'd like to call MyService.update()
The parts I'm not clear on: What is the object being passed to Notes doing? Why does Notes.update need to have 2 parameters passed to it? I'm currently getting the data fine but I'm getting some errors when trying to PUT. All the examples use these parameters though so I'm just wondering what these parameters are used for.
*Specifically the error is "Method PUT is not allowed by Access-Control-Allow-Methods." even though it is. Strangely, I click on the error in Chrome networks tab and it says 200 OK. I'm guessing the OPTION command went through to check if PUT is allowed but then PUT fails.
Request Method:OPTIONS
Status Code:200 OK
Access-Control-Request-Headers:accept
Access-Control-Request-Method:PUT
Access-Control-Allow-Headers:*
Access-Control-Allow-Methods:*
Access-Control-Allow-Origin:*
Access-Control-Max-Age:3600
Allow:GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
Content-Length:0
Date:Mon, 17 Mar 2014 21:39:26 GMT
Server:Apache-Coyote/1.1