@@ -90,7 +90,7 @@ function shallowClearAndCopy(src, dst) {
9090 * when a param value needs to be obtained for a request (unless the param was overridden).
9191 *
9292 * Each key value in the parameter object is first bound to url template if present and then any
93- * excess keys are appended to the url search query after the `?`.
93+ * excess keys are appended to the url seapph query after the `?`.
9494 *
9595 * Given a template `/path/:verb` and parameter `{verb:'greet', salutation:'Hello'}` results in
9696 * URL `/path/greet?salutation=Hello`.
@@ -272,6 +272,35 @@ function shallowClearAndCopy(src, dst) {
272272 });
273273 });
274274 </pre>
275+
276+ * @example
277+ * # Creating a custom 'PUT' request
278+ * In this example we create a custom method on our resource to make a PUT request
279+ <pre>
280+ var app = angular.module('app', ['ngResource', 'ngRoute']);
281+
282+ // Some APIs expect a PUT request in the format URL/object/ID
283+ // Here we are creating an 'update' method
284+ app.factory('Notes', ['$resource', function($resource) {
285+ return $resource('/notes/:id', null,
286+ {
287+ 'update': { method:'PUT' }
288+ });
289+ }]);
290+
291+ // In our controller we get the ID from the URL using ngRoute and $routeParams
292+ // We pass in $routeParams and our Notes factory along with $scope
293+ app.controller('NotesCtrl', ['$scope', '$routeParams', 'Notes', function($scope, $routeParams, Notes) {
294+ // First get a note object from the factory
295+ var note = Notes.get({ id:$routeParams.id });
296+ $id = note.id;
297+
298+ // Now call update passing in the ID first then the object you are updating
299+ Notes.update({ id:$id }, note);
300+
301+ // This will PUT /notes/ID with the note object in the request payload
302+ }]);
303+ </pre>
275304 */
276305angular . module ( 'ngResource' , [ 'ng' ] ) .
277306 factory ( '$resource' , [ '$http' , '$q' , function ( $http , $q ) {
0 commit comments