https://gyazo.com/458395bd24fee3bd8e868bd8973b3073 This is the JSON
https://gyazo.com/d951c7ea1d40f8001293963f25f78745 These are the cards generated from the JSON
In the card you can see the student and “groep” is which group he is in. I want to count all the students in a certain group. Example: 8 students groep 3 and I want to show that in a card.
Thanks in advance!
Loop through all items, for each one add 1 to an array with the groups. At the end you have an array with all groups and the number of students in it that you can use.
<ion-card>
<ion-item ng-repeat="item in items|groupBy:'groep'">
Students : {{item.length}}
</ion-item>
</ion-card>
you can use the groupBy
That doesnt work for me. Runtime Error
Error in ./Page2 class Page2 - caused by: Cannot read property ‘length’ of undefined
rahulpzy:
$scope.players = [
{name: ‘Gene’, team: ‘alpha’},
{name: ‘George’, team: ‘beta’},
{name: ‘Steve’, team: ‘gamma’},
{name: ‘Paula’, team: ‘beta’},
{name: ‘Scruath’, team: ‘gamma’}
];
<ion-card>
<ion-item ng-repeat="player in players| groupBy: 'team' ">
Students : {{player.length}}
</ion-item>
</ion-card>
this my data its work fine just change your array to a $scope variable
Typescript Error
Cannot find name ‘$scope’. and where do you define it
are you using angular 2 my example is for angular 1 only?
Do you have something similar with a for loop or something because I have never worked with pipe and I dont know what to change and what to do… I’m sorry for being annoying but I really want to know it.
Look at this example: https://angular.io/docs/ts/latest/guide/pipes.html
Pipes are really easy to use
Thank you. I’ll try my best!