title: Angular - Update Every Property Of An Object After Resource Save
body: <p>I'm passing an object to a resource, which makes some database updates that could change multiple properties of the object (beyond the changes made in the UI).  </p>
  
  <p>If I update the properties individually, the changes are reflected in the HTML.  But if I try to update the entire object, the changes are not reflected.</p>
  
  <p>So, this works:</p>
  
  <pre><code>myResource.doSomething(item)
      .$promise
      .then(function (response) {
          item.Color = response.Result.Color;
          item.Shape = response.Result.Shape;
      });
  </code></pre>
  
  <p>But this doesn't:</p>
  
  <pre><code>myResource.doSomething(item)
      .$promise
      .then(function (response) {
          item = response.Result;
      });
  </code></pre>
  
  <p>What's the best way to update every property of the object?</p>
  
  <p>In case it helps, here's my resource (posts to an MVC controller which returns JSON of the updated object):</p>
  
  <pre><code>app.factory('myResource', function ($resource) {
      return {
          doSomething: function (item) {
              return $resource('/Something/Do/:Id', { Id: item.Id }).save();
          }
      };
  });`
  </code></pre>
  
  <p>EDIT: To clarify, the item is part of a collection bound to an ng-repeat directive, e.g.:</p>
  
  <pre><code>&lt;tr ng-repeat="item in items" &gt;
      &lt;td&gt;
          &lt;a ng-click="doSomething(item)" &gt;Do Something&lt;/a&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>