What is the most efficient method for searching a specific parameter within an object array in Angular?
I am populating my array using Angular's foreach method:
$scope.arrayiwanttosearch = [];
angular.forEach(data, function(value, key) {
try{
var arrstring = new Array();
arrstring = value.img.split(',');
obj.name = value.name;
obj.selectedcolor = arrstring[0];
obj.colors = value.img;
obj.ischanging = false;
$scope.arrayiwanttosearch.push(obj);
}
catch(ex){
}
})
Using array.indexOf only works for arrays without objects. Is there a way to accomplish this without resorting to a for loop? My goal is to identify the index of the object with obj.name == "test".