title: Angular - Only push to array if unique
body: <p>I have an Angular application that collects values of items for an invoice, I want to make sure only unique items are being added to this collection but am having no luck.</p>
  
  <p>I am pushing 3 pieces of information to this collection: id, price, and type. I want to make sure there is nothing in the collection currently matching those 3 points.</p>
  
  <pre><code>// My container
  $scope.invoice = {
      items: [{
      }]
  }
  
  
      $scope.addPhoto = function() {
      console.log('Withdrawing Photo: '+ $scope.item.id);
      if ($scope.invoice.items.indexOf(item.id) != $scope.item.id)
      {
        $scope.invoice.items.push({
          id: $scope.item.id,
          price: $scope.item.price,
          type: 'photo'
      });
      }
  }
  </code></pre>
  
  <p>// Trying to avoid collections like this</p>
  
  <p>invoice:  { 
  items: 
  [  {  } ,  { 
  id: 25
  price: 0
  type: photo
   } ,  { 
  id: 25
  price: 0
  type: photo
   }  ]
   } </p>
  
  <p><img src="https://i.stack.imgur.com/5OHVU.png" alt="enter image description here"></p>