You can use your resource in two ways for your example, and that is what you are using ...
app.factory('Notes', ['$resource', function($resource) { return $resource('/notes/:id', null, { 'update': { method:'PUT' } }); }]);
So, the first way to update a note:
Notes.update({ id: 42 }, { Content: "My Note" });
As shown on the site, the first object is the parameter object, so you will put it in "/ notes / 42", the second object is the object that you put, that is, it will be the content for the request.
There is also a second option:
var note = Notes.get({ id: 42 }); note.Content = "Changed the note"; node.$update({ id: 42 });
Finally, if you configure your resource to map the properties of the returned object to the parameters, you can avoid providing the identifier in the $ update call like this:
app.factory('Notes', ['$resource', function($resource) { return $resource('/notes/:id', { id:'@ID'}, { 'update': { method:'PUT' } }); }]);
And then:
var note = Notes.get({ id: 42 }); note.Content = "Changed the note"; node.$update();
Assuming the server returns { Content: "My Note", ID: 42 } to the get call.
NOTE: Keep in mind that they are all simplified; the last 2 of them do not actually work due to the asynchronous nature of the resource. To fix this directly in the above example, add a Success handler or use the Promise object ... So:
var note = Notes.get({ id: 42 }, function() { note.Content = "Changed the note"; node.$update({ id: 42 }); });
and
var note = Notes.get({ id: 42 }, function() { note.Content = "Changed the note"; node.$update(); });
Accordingly ... It works for them, but get-update-put is thus unlikely, instead you should usually interact with the user.
I honestly have never had a problem. Issuing a PUT request, so why are your mistakes that I cannot handle.
To help you debug your situation, I can recommend using, for example, (Or any other tool that allows you to create HTTP requests and change headers, etc.), https://chrome.google.com/webstore/detail/ dev-http-client / aejoelaoggembcahagimdiliamlcdmfm? hl = en
To check if your servlet really doesn’t accept tagging at this URL. If the server really accepts puts (you will be able to execute PUT with this tool), the next thing will be to actually put the correct URL ...
We often use this small interceptor to register all Angular requests (therefore, they are separate from regular browser requests, for example, getting styles, images, etc.).
myModule.config(['$httpProvider', function ($httpProvider) { $httpProvider.interceptors.push(['$q', function ($q) { return { 'request': function (config) { var paramsStr = [], prefix = ""; angular.forEach(config.params, function (val, key) { paramsStr.push(key + "=" + val); prefix = "?"; }); console.log(config.method + ": " + config.url + prefix + paramsStr.join('&')); return config || $q.when(config); } }; }]); }]);