title: AngularJS $resource RESTful example
body: <p>I would like to use $resource to call my RESTful web service, (which I am still working on) but I would like to find out if I got my AngularJS script correct first.</p>
  
  <p>The todo DTO has: <code>{id, order, content, done}</code></p>
  
  <p><code>:cmd</code> is so I can call <code>api/1/todo/reset</code> to clear the todo table in database.</p>
  
  <p>Here is the code with comment of my understanding:</p>
  
  <pre><code>function TodoService($resource) {
      var src = $resource('api/1/todo/:id:cmd',
                {id: "@id", cmd: "@cmd"}, //parameters default
                {
                  ListTodos: { method: "GET", params: {} },
                  GetTodo: { method: "GET", params: { id: 0 } },                            
                  CreateTodo: { method: "POST", params: { content: "", order: 0, done: false } },
                  UpdateTodo: { method: "PATCH", params: { /*...*/ } },
                  DeleteTodo: { method: "DELETE", params: { id: 0 } },
                  ResetTodos: { method: "GET", params: { cmd: "reset" } },
                });
  
      //Usage:
  
      //GET without ID
      //it calls -&gt; api/1/todo
      src.ListTodos();
  
      //GET with ID
      //it calls -&gt; api/1/todo/4
      src.GetTodo({ id: 4 });
  
      //POST with content, order, done
      //it calls -&gt; api/1/todo
      src.CreateTodo({ content: "learn Javascript", order: 1, done: false });
  
      //UPDATE content only
      //it calls -&gt; api/1/todo/5
      src.UpdateTodo({ id: 5, content: "learn AngularJS" }); 
  
      //UPDATE done only
      //it calls -&gt; api/1/todo/5
      src.UpdateTodo({ id: 5, done: true });
  
      //RESET with cmd
      //it calls -&gt; api/1/todo/reset
      src.ResetTodos();
  }
  </code></pre>
  
  <p>One particular thing I am not sure is the PATCH method, I don't want to update everything, can I update just one field? Am I constructing this piece of code correctly?</p>