i have the following array:
items: [
{
id: "0",
name: "כיבוי אורות",
icon: "rooms_salon.svg",
type: "scenario",
status: 1
},
{
id: "1",
name: "הדלקת אורות",
icon: "rooms_salon.svg",
type: "scenario",
status: 1
},
{
id: "0",
name: "תנור מטבח",
icon: "rooms_salon.svg",
type: "heater",
status: 0
},
{
id: "1",
name: "מזגן מטבח",
icon: "rooms_salon.svg",
type: "ac",
status: 0
}]
i need to filter it so i get only unique item.type and the count of the original amount of items per type.
the resolute i need:
items: [
{
type: "scenario",
amount: 2
},
{
type: "heater",
amount: 1
},
{
type: "ac",
amount: 1
}
]
What would be the best way to do so?
P.O: i need to filter it in the controller, not in ng-repeat.
Thanks allot
Avi