@aligassan wrote:
l am working on ionic 4 project. My project is getting data
json
from url content flights schedules . Everything is okay , but l want to usebutton boolean
when users click on button show to users the flights schedules for yesterday . l don`t want to create another page for holding flights schedules for yesterday l want used in same page and same code . l did like this but when l click on button he is not load any information shows for flights schedules yesterdayLoadearlierflights : boolean = true; async getData() { const loading = await this.loadingController.create({ message: 'Loading' }); await loading.present(); /// flights details for today /// if (this.Loadearlierflights=true) { this.http.get('xxxxxxx/airport.json?code=bsr', {}, {}) .then(data => { this.test = JSON.parse(data.data); const parsed = JSON.parse(data.data); this.items = parsed.pluginData.schedule.arrivals.data; loading.dismiss() console.log(this.items) }), err=>{ this.test =err loading.dismiss() } /// flights details for yesterday /// }else if (this.Loadearlierflights=false) { this.http.get('xxxxxxxx/airport.json?code=bsr&page=-1', {}, {}) .then(data => { this.test = JSON.parse(data.data); const parsed = JSON.parse(data.data); this.items = parsed.pluginData.schedule.arrivals.data; loading.dismiss() console.log(this.items) }), err=>{ this.test =err loading.dismiss() } }
html
<ion-button shape="round" (click)="getData()">load earlier flights</ion-button>
any ideas please ?
Posts: 4
Participants: 2