How could I scan an array of objects in order to find an object by matching the object property:
$scope.items = [
{ id: 1, name: \'one\' },
{ id: 2, name: \
You can use Angular's built-in filter functionality to perform the search:
$scope.filteredItems = function() {
return $filter($scope.items, id == filterID);
}
Here is a fiddle showing the filter in action: http://jsfiddle.net/wittersworld/xV8QT/
I Used Underscore js
$scope.item = _.where($scope.items, { id: 1 });
You can also use filter method like this:
$scope.items.filter(function (item) {
return item.id === 1; }
)