title: How to modify json object in array of object
body: <p>I have an array of object</p>
  
  <pre><code>// This is should be taken from database
  $scope.users = [{"$id":"1","UserID":3,"Name":"A","Selected":false},{"$id":"2","UserID":4,"Name":"B","Selected":false},{"$id":"3","UserID":5,"Name":"C","Selected":false},{"$id":"4","UserID":6,"Name":"D","Selected":false}]
  </code></pre>
  
  <p>Then there is an array that contains the selected users from previous screen</p>
  
  <pre><code>$scope.usersSelected = [{"$id":"3","UserID":5,"Name":"C","Selected":true,"$$hashKey":"object:83"},{"$id":"4","UserID":6,"Name":"D","Selected":true,"$$hashKey":"object:84"}]
  </code></pre>
  
  <p>I want to update the <code>Selected</code> properties of <code>$scope.users</code> if they are found in <code>$scope.usersSelected</code>. So I iterate the <code>$scope.usersSelected</code> then search its <code>UserID</code> in the <code>UserID</code> of <code>$scope.users</code></p>
  
  <pre><code>for (var i = 0; i &lt; $scope.usersSelected.length; i++) {
      var obj = $.grep($scope.users, function (e) { return e.UserID == $scope.usersSelected[i].UserID; });
      obj.Selected = true;
  }
  </code></pre>
  
  <p>but the <code>Selected</code> properties won't be updated. What's wrong with the code above?</p>
  
  <p>Second, I need an explanation regarding the data in array above, why there is always <code>"$id"</code> when I populate the data from the database and also <code>"$$hashKey"</code> when I get the data from another screen? Where do these values come from?</p>
  
  <p>Notes: I'm using AngularJS with ASP.NET Web API 2 to get the data from database.</p>