In my attempt to dynamically fetch data on scroll and populate an array of "Article[]".
httpLoadArticles() {
this.httpWSGetInit().subscribe(
articles => this.articles = articles,
err => {
console.log(err);
},
() => console.log('Search complete')
}
Presenting the current function below.
httpWSGetInit() : Observable<Article []> {
return this.http.get(R.WEBSITE_URL_WS + this.articlesPagination)
.map((res:Response) => res.json())
.catch((error:any) => Observable.throw(error.json().error || 'Server error'));
}
The functionality works effectively.
However, the http.get
method is not triggered within addScrollListener
.
@ViewChild(Content) content: Content;
ionViewDidLoad() {
this.content.addScrollListener(this.onPageScroll);
}
onPageScroll(event) {
this.httpLoadArticles()
}
I attempted to make the GET
request synchronous, but it appears to have no effect. Could this be a scope-related issue? For instance, does addScrollListener
function solely as a JavaScript method and cannot be linked to an Angular2 container?