title: How do you update an existing item in an Angular Array (that has changed externally)?
body: <p>I am new to Angular and am struggling with updating an existing item in my Angular array that has changed externally (not via Angular powered UI). </p>
  
  <p>Here is the use case...My web page is populated via a server side call and I am loading the array into Angular and displaying on a list. </p>
  
  <p>Now, if the data on the server changes and a new record is inserted in the table, my page's JavaScript is notified and it successfully inserts a new records into the Angular array via 'push' (Ref. <a href="https://stackoverflow.com/questions/23860072/programmatically-inserting-array-values-in-angular-js">Programmatically inserting array values in Angular JS</a>). </p>
  
  <p>However, my page is also notified when an existing record is changed (on the server side / not via Angular powered UI). I am drawing a blank about how do I go about updating the correct record in my Angular array? Is there a query / update method that I have missed in the Angular docs?</p>
  
  <p>Here is what my current code looks like...</p>
  
  <pre><code>    //The HTML UI updates to reflect the new data inserts.
      &lt;div ng-repeat="item in items"&gt;        
          &lt;p class="priority"&gt;{{item.priority_summary}}&lt;/p&gt;
          &lt;p class="type"&gt;{{item.type}}&lt;/p&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Here is the Script...</p>
  
  <pre><code>    var app = angular.module('DemoApp', []);
  
      &lt;!-- Define controller --&gt;
      var contrl = app.controller("MainController", function ($scope) {
  
      $scope.items = [{
          "status": "New",
              "priority_summary": "High"
      }, {
          "status": "New",
              "priority_summary": "High"
      }, {
          "status": "New",
              "priority_summary": "High"
      }, {
          "status": "New",
              "priority_summary": "High"
      }];
  
  //The insert works fine. The question is how do I do an update if the notification is for an update, and not for insert.
  
      $scope.addItem = function(item)
      {
       alert("addItem called");
       $scope.items.push(item);
       $scope.item = {};
      }
  
        $scope.subscribe = function(){
          //Code for connecting to the endpoint...
          alert("event received"); //We receive this alert, so event is received correctly.
  
          $scope.items.push({
            status: 'New',
            priority_summary: 'H'
          });
          $scope.$apply();
  
          }
  
        //calling subscribe on controller initialization...
        $scope.subscribe();
  </code></pre>
  
  <p>Any suggestions or examples highlighting this would be great. Thanks!</p>