title: Initializing an angular resource object instance without calling the server
body: <p>In <code>Backbone.js</code>, one can instantiate a model with pre-existing JSON data by using</p>
  
  <pre><code>var user = new Backbone.Model({ name: "John Doe", age: 30 });
  </code></pre>
  
  <p>And then perform updates with a single call</p>
  
  <pre><code>user.save({ age: 31 }, { success: successCallback, error: errorCallback });
  </code></pre>
  
  <p>This comes handy in all sorts of scenarios, such as when that data is already available on the client through caching or pre-populated templates (like using <code>&lt;%= raw @user.to_json %&gt;</code> in rails erb templates). </p>
  
  <p>I'm curious to know how this is done when using <code>$resource</code> with <code>Angular.js</code>. Right now, I have a situation where my data is cached on the client before the <code>$resource</code> is created, and I'd like to update it without making an extra <code>GET</code> call to populate the object:</p>
  
  <pre><code>app.factory('User', ['$resource', function($resource) {
      return $resource('/users/:user_id.json', { user_id: '@id' }, {
          get: { method: 'GET' },
          save: { method: 'PUT' },
          create: { method: 'POST' },
          destroy: { method: 'DELETE' }
      });
  }]);
  </code></pre>
  
  <p>And somewhere in my controller I'd like to just update an existing user without fetching it from the server:</p>
  
  <pre><code>app.controller('UsersController', ['User', function(User) {
      // somehow initialize a user from an existing
      // object, say { name: "John Doe", age: 30 }
      user.age = 31
      user.$save()
  
      // instead of doing this
      User.get({ user_id: 100 }, function(user, respHeaders) {
          user.age = 31
          user.$save()
      }); 
  }]);
  </code></pre>
  
  <p>I'm probably still in the Backbone mindset, but I'm really curious if I'm approaching this all wrong. Thanks.</p>