Issue
I have an array of objects:
[{name: "Mary", "salary": "22k", "category": "A", "dob": 1992},
{name: "Bob", "salary": "22k", "category": "A", "dob": 1994},
{name: "Paul", "salary": "22k", "category": "A", "dob": 1994},
{name: "Christy", "salary": "22k", "category": "A", "dob": 1993},
{name: "John", "salary": "22k", "category": "A", "dob": 1993},
{name: "Kenny", "salary": "22k", "category": "A", "dob": 1993},
}]
I am displaying these from the template using *ngFor. But now I need to categorize based on dob (it will be grouped in order as shown) and display them under 1 title.
Ex:
Year 1992 Mary
Year 1994 Bob Paul
Year 1993 Christy John Kenny
I can achieve this by matching the index value or some other logic in a function. But let's just say we need to handle this only through *ngIf and *ngFor (or any other template changes). Is there a way?
Solution
I just found this solution from another post. Had to only update the HTML: https://stackoverflow.com/a/58923774/4567978
Answered By - Kavya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.