I am trying to group by array in angular 4. I am using the custom pipe approach to group by the array as found in:
https://www.competa.com/blog/custom-groupby-pipe-angular-4/
But I am trying to group by multiple columns.
Data
var myArray = [
{
name: "Apple",
color: "Green",
grade: "A1"
},
{
name: "Apple",
color: "Red",
grade: "A1"
},
{
name: "Apple",
color: "Green",
grade: "A2"
},
{
name: "Apple",
color: "Red",
grade: "A2"
},
];
Here I want to group by multiple columns say, name and Grade.
I have tried using like this with no help:
<li *ngFor="let object of myArray | groupBy:'name,grade'"></li>
Please provide your valuable solutions to resolve this issue. Appreciate your help. Thanks.