Say I have an object like this
$scope.products = {
blueDuck: {type:'duck', price: 5},
redDuck: {type:'duck', price: 8},
greenWolverine: {type:'wolverine', price:15}
}
I want to loop over the elements by type:
angular.forEach($scope.products, function(key, value) {
console.log(value.type);
});
That would output:
duck
duck
wolverine
When I want to get a variable that's like:
duck
wolverine