Good evening,
I have a question about refreshing data which is loaded from an external json file. My script is this for now and at the doRefresh part I have to change something but dont know how
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { HttpClient } from '@angular/common/http';
import "rxjs/add/operator/map";
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
users=[];
page = 0;
maximumPages = 10;
text:any = {
Year: 'Year',
Month: 'Month',
Weeks: "Weeks",
Days: "Days",
Hours: "Hours",
Minutes: "Minutes",
Seconds: "Seconds",
MilliSeconds: "MilliSeconds"
};
constructor(public navCtrl: NavController, private httpClient: HttpClient) {
this.loadUsers();
}
loadUsers(infiniteScroll?) {
this.httpClient.get(`http://bla.nl/res/nieuws?page=${this.page}`)
.subscribe(res => {
this.users = this.users.concat(res['results']);
if (infiniteScroll) {
infiniteScroll.complete();
}
})
}
loadMore(infiniteScroll) {
this.page++;
this.loadUsers(infiniteScroll);
if (this.page === this.maximumPages) {
infiniteScroll.enable(false);
}
}
doRefresh(refresher) {
console.log('Begin async operation', refresher);
.subscribe(res => {
this.users = this.users.concat(res['results']);
});
}
}
For now I get Declaration or statement expected. How can I add something before .subscribe which can work?