title: Edit object via modal in AngularJS - use a temporary object?
body: <p><strong>Scenario:</strong> User clicks on item.  Following code runs and opens a modal with a textbox that has the item's name populated.</p>
  
  <pre><code>$scope.edit = function (item) {
      $scope.editingItem = { Name: item.Name };
  };
  </code></pre>
  
  <p>My HTML within the modal:</p>
  
  <pre><code>&lt;input type="text" ng-model="editingItem.Name"/&gt;
  </code></pre>
  
  <p>This works fine, the modal shows (using <code>ng-show</code>) and the textbox is populated with the item's name.</p>
  
  <p><em>Im using a new object to populate the textbox because I don't want the original object to change (via AngularJS auto data binding) until I press the save button.</em></p>
  
  <p>Then this HTML:</p>
  
  <pre><code>&lt;a href="" ng-click="update(editingItem)"&gt;Save&lt;/a&gt;
  </code></pre>
  
  <p>Leads to:</p>
  
  <pre><code>$scope.update = function (item) {
      // What do I put in here to update the original item object that was passed
      // into the edit function at the top of this question?!
  };
  </code></pre>
  
  <p>My issue though is what to put into the <code>update</code> method? I want to update the original <code>item</code> (held in an array of items).</p>