-1

I have a mat-list and I am displaying category and name with data in it. Please note the stackblitz: https://stackblitz.com/edit/angular-material-list-krzxrz?file=app%2Fapp.component.ts

What I need is to arrange is so that the category Fruits comes as heading with the fruit names under it, and then the same with vegetables.

Jojofoulk
  • 2,127
  • 1
  • 7
  • 25
androidGenX
  • 1,108
  • 3
  • 18
  • 44

1 Answers1

1

If what you want to achieve is display each item of a category under a header with that category name, a possible approach is to group your array of object (simpleItems) by name and then use the keyvalue pipe to print the key followed by the elements.

Here's a Stackblitz example.

Hope this helps.

Jojofoulk
  • 2,127
  • 1
  • 7
  • 25