title: Angularjs compare two objects in ng-options
body: <p>I have two arrays of objects. 
  A very simplified example:</p>
  
  <pre><code>$scope.genres = [
      {
        id: '123',
        name: 'Genre 1'
      },
      {
        id: '124',
        name: 'Genre 2'
      },
      {
        id: '125',
        name: 'Genre 3'
      }
    ];
  
    $scope.selectedGenres = [{
        id: '123',
        name: 'Genre 1'
      }];
  </code></pre>
  
  <p>I use <strong>genres</strong> to populate a select. </p>
  
  <pre><code>&lt;select style="height: 100px; width: 100%;"
                          multiple
                          ng-model="selectedGenres"
                          ng-options="option as option.name for option in genres"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>I realise doing: <code>$scope.selectedGenres = [$scope.genres[0]];</code>
  Would work as the objects reference is the same. </p>
  
  <p>Is there any way to compare the two objects for equality rather than their reference? </p>
  
  <p>Example: <a href="http://jsbin.com/cizuyitadu/6/edit" rel="nofollow">http://jsbin.com/cizuyitadu/6/edit</a></p>