Currently I have my scope set out in the following format.
$scope.test = [
{
group: 'Group1',
groupID:0,
items: [
{id: 0, description: 'Item 1', error: true, groupID:0},
{id: 1, description: 'Item 2', error: true, groupID:0},
{id: 2, description: 'Item 3', error: true, groupID:0},
{id: 3, description: 'Item 4', error: true, groupID:0}
]
},
{
group: 'Group2',
groupID:1,
items: [
{id: 0, description: 'Item 1', error: true, groupID:1},
{id: 1, description: 'Item 2', error: true, groupID:1},
{id: 2, description: 'Item 3', error: true, groupID:1},
{id: 3, description: 'Item 4', error: true, groupID:1}
]
},
{
group: 'Group3',
groupID:2,
items: [
{id: 0, description: 'Item 1', error: true, groupID:2},
{id: 1, description: 'Item 2', error: true, groupID:2},
{id: 2, description: 'Item 3', error: true, groupID:2},
{id: 3, description: 'Item 4', error: true, groupID:2}
]
}
What I want is too loop through all the item objects in each parent object inside the controller and get a total of all items which the value 'error' is equal to true and alert this total.
Currently inside the controller I can only loop through the 1st level objects in the array, so can only access 'group' and 'groupID'.