latest-news.html
update function
<ion-refresher (ionRefresh)="doUpdate($event)">
<ion-refresher-content pullingText="pull to update">
</ion-refresher-content>
</ion-refresher>
retrieve latest news from server
<ion-list *ngSwitchCase="'latest-news'">
<ion-card>
<ion-item-group (click)="viewLatestNewsDetail(latest)" text-wrap *ngFor="let latest of latestNews">
<ion-thumbnail *ngIf="latest.Preview_image1" item-start>
<img src="{{latest.Preview_image1}}">
</ion-thumbnail>
<ion-card-content>
<ion-item>
<ion-card-title>{{latest.title}}</ion-card-title>
<p>{{latest.news_category}}</p>
<h3>{{latest.publish_time}}</h3>
</ion-item>
</ion-card-content>
</ion-item-group>
</ion-card>
</ion-list>
latest-news.ts
doUpdate(refresher){
console.log('Begin async operation', refresher);
setTimeout(() => {
console.log('Async operation has ended');
refresher.complete();
}, 1500);
}
retrieve latest news data
constructor(public navCtrl: NavController,
public navParams: NavParams,
public newsData:NewsDataProvider){
this.retrieveLatestNews();
}
retrieveLatestNews() {
this.newsData.getLatestNews().then(data => {
this.latestNews = data;
});
}
I am attempting to update the latest news list and fetch new news data from the server. Although this code is sourced from the Ionic2 documentation, I am encountering issues.
Edit: The following code snippet is what I included in latest-news.ts. There are no errors displayed, but after performing the update, the news list remains empty.
doUpdate(refresher){
this.retrieveLatestNews().then(() => {
refresher.complete();
});
}
retrieveLatestNews(): Promise<any> {
return this.newsData.getLatestNews().then(data => {
this.latestNews = data;
});
}