.html
<ng-container *ngFor="let contact of listContact | async; let index = index;">
<h6 class="title" *ngIf="contact && contact['type']">
{{contact['type']}}
</h6>
<div> {{contact['id']}}</div>
</ng-container>
listContact an observable contains:-
[
{
"id": "u-8cf4161b-240f-5d7a-b5df-0522739c62d9",
"type": "Peoples"
},
{
"id": "u-0580ff64-c959-5690-bc54-16c43b28065d",
"type": "Peoples"
},
{
"id": "u-44e5a40a-a367-55e0-baf1-1eacccafe5f2",
"type": "Teams"
}
]
The expected(desired) html output:-
Peoples
u-8cf4161b-240f-5d7a-b5df-0522739c62d9
u-0580ff64-c959-5690-bc54-16c43b28065d
Teams
u-44e5a40a-a367-55e0-baf1-1eacccafe5f2
How to add a check that if previous {{contact['type']}}
in for loop is same as current {{contact['type']}}
in for loop , then not add {{contact['type']}}
in view. title is dependent on {{contact['type']}}
and too should not repeat until previous {{contact['type']}}
is different from current one.
How to handle it in html for this issue?