title: Angular update object in array
body: <p>I wanna update an object within an objects array. Is there another possibility than iterating over all items and update the one which is matching? Current code looks like the following:</p>
  
  <pre><code>angular.module('app').controller('MyController', function($scope) {
      $scope.object = {
          name: 'test',
          objects: [
              {id: 1, name: 'test1'},
              {id: 2, name: 'test2'}
          ]
      };
  
      $scope.update = function(id, data) {
          var objects = $scope.object.objects;
  
          for (var i = 0; i &lt; objects.length; i++) {
              if (objects[i].id === id) {
                  objects[i] = data;
                  break;
              }
          }
      }
  });
  </code></pre>