Pull to refresh trigger on ionViewDidEnter - Need to pass event object

Hi All, I am wondering how I can trigger the pull to refresh function using ionViewDidEnter().

I can easily just call my doRefresh() function in the ionViewDidEnter() method, but how can I pass in a $event object so that refresher.complete(); can still be called at the end of it.


ionViewDidEnter() {

	this.doRefresh(); -- I need to pass in here somehow


doRefresh(refresher) {

	this.notificationservice.refreshNotifications().then((response) => {

		response = JSON.parse(response['_body']);

		let notifications = new Array();

		for(let key in response)
			response[key].dateago = moment(response[key].date, 'YYYY-MM-DD H:mm:ss').fromNow();
			notifications[key] = response[key];

		this.notifications = notifications;

		this.notificationservice.notifications = notifications;




<ion-refresher (ionRefresh)="doRefresh($event);">
		<ion-refresher-content pullingIcon="arrow-dropdown" pullingText="Pull to refresh" refreshingSpinner="circles" refreshingText="Refreshing...">

The way I have done this is to simply have 2 different refreshers/loaders. I’m not sure what you’re wanting to do is possible. In your case you could simply if(refresher) refresher.complete() to avoid an error, and just stick to using 1 function (though missing an animation so the user can see that it is refreshing, when they haven’t performed a pull to refresh)

Makes sense, I think I can deal with the lack of animation. Many Thanks for your time.

Try something like this,

    ionViewDidEnter() {


The null isn’t needed, if you want your compiler to stop complaining you should do

doRefresh(refresher?) { ... }
1 Like