I have created array in my ts file and with ngFor get elements from array, but when I use key value angular is automatically sorting the array. How to save the order like array was created.
TS code:
filterListingTypeItems: { [key: string]: object } = {
'For sale': [
'For sale',
'By Agent',
'By ownre',
'New Construction',
'Foreclosures',
'Coming Soon',
],
'Potential listings': [
'Potential listings',
'Foreclosed',
'Pre-Foreclosure',
'Make Me Move',
],
'For Rent': ['For Rent'],
'Recently sold': ['Recently sold'],
_________________________: ['Open House only', 'Pending & Under Contract'],
}
HTML code (angular material):
<mat-optgroup
*ngFor="let listingOptions of (filterListingTypeItems | keyvalue)"
[label]="listingOptions.key"
>
<mat-option
*ngFor="let listingOption of listingOptions.value"
[value]="listingOption"
>{{ listingOption }}</mat-option
>
</mat-optgroup>