Hi, i have to make some dynamic filters for a list, and i don’t know how to fetch the data/initialize the already selected values.
Here’s my template:
<ion-content>
<ion-list>
<ion-item *ngFor="let filter of store.filters$ | async">
<ion-label>{{ filter.type }}</ion-label>
<ion-select [ngModel]="filter[filter.type]" (ionChange)="onChange($event, filter.type)">
<ion-option *ngFor="let filter of filter.filters" value="{{ filter.id }}">{{ filter.name }}</ion-option>
</ion-select>
</ion-item>
</ion-list>
</ion-content>
Here the filters (that data have been get with an http request, they can change, some filter can disapear, the order can change)
[
{
"type": "regions",
"filters": [
{
"id": "3027257",
"name": "Champagne-Ardenne",
"has_show": false
},
{
"id": "6691708",
"name": "Collectivité territoriale de Saint-Pierre-et-Miquelon",
"has_show": false
}
]
},
{
"type": "themes",
"filters": [
{
"id": "17",
"name": "Tourisme, hôtellerie, restauration",
"has_show": true
},
{
"id": "33",
"name": "Transport, logistique",
"has_show": true
}
]
}
]
If somebody can help me with that please.