I have an Angular app that collects item values for an invoice, I want to make sure that only unique items are added to this collection, but I'm out of luck.
I click 3 pieces of information in this collection: id, price and type. I want to make sure that there is nothing in the collection that matches these three points.
$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'
});
}
}
// Try to avoid such collections
account: {Items: [{}, {id: 25 price: 0 Type: photo}, {id: 25 price: 0 Type: photo}]}

source
share