First: I’m a newbie to develop apps with ionic (angular,typescript).
Secondly: I do not know how I can best describe it as a php snippet to use, sorry for that.
I wold like to do following data filtering in a template:
foreach ($content as $item){
if (isset($districts[$item[‘name’]){
print $item[‘name’];
print $item[‘date’];
… etc
}
}
How I can build this in a template to use ion-list, ion-item and ngFor or similar?
Thank you for help
I’m not sure where your data is coming from, but the way I’d do it is filter in the controller as shown here:
public items = []; //Preferably you'd have a type here
ionViewWillEnter() {
this.items = inputData.filter(item => !!districts[item.name]);
}
Then you can just use *ngFor*
in your template like so:
<ion-list>
<ion-item *ngFor="let item of items">
<h2>{{item.name}}</h2>
<p>{{item.date}}</p>
</ion-item>
</ion-list>
content ist a ‘trash calendar’
The datas coming from a database, content and districts are json objects.
User choose their street and that affects the data in districts.
Users should get only the data from content with district are in districts.