I have the following Angular code, see below.
What I'd like to achieve is - for each user - find out the "count" for each activity type.
What I'd like to achieve is:
John Thompson = 2 Deal
Bill Gates = 3 Deal
Billy Wellington = 2 Deal, 1 Meeting
The activity id's are the same in the activities object, and the $scope.activities.
Bit stuck here, any idea on how to either a) Write a function to get the COUNT or b) Do something clever in the HTML element with a ng-repeat and group or something.
$scope.competitionDetails = {
end_date: "2014-03-01",
users: [{
id: 2,
name: "John Thompson",
activities: [{ //This is all their activities
id: 6431,
time: (57).minutes().ago(),
points: 20
}, {
id: 6431,
time: new Date(),
points: 20
}]
}, {
id: 3,
name: "Bill Gates",
activities: [{ //This is all their activities
id: 6431,
time: new Date(),
points: 20
}, {
id: 6431,
time: new Date(),
points: 20
}, {
id: 6431,
time: new Date(),
points: 20
}]
}, {
id: 1,
name: "Billy Wellington",
activities: [{ //This is all their activities
id: 6431,
time: new Date(),
points: 20
}, {
id: 6431,
time: new Date(),
points: 20
}, {
id: 6432,
time: new Date(),
points: 100
}]
}]
};
$scope.activities = [{
id: 6431,
name: "Deal",
points: 20
}, {
id: 6432,
name: "Meeting",
points: 100
}];