×

Ionic Refresher

Refresher means updating the currently showing page so that the user can see the latest view. It is also known as re-loading in web technology.

It provides a pull- to-refresh feature on a content component. The pull-to-refresh feature allows the user to pull or drag a page down to some limit, and then the current page view is automatically got a refresh. The Ionic permits you to use this pattern on a list of data using touch to get more data.

Ionic provides the <ion-refresher> component to add a pull-down feature. The <ion-refresher> component gives pull-to-refresh feature on a content component. The data should be modified through refresher’s output events. Once the refresher of pages end, then call the complete() method.

Ionic Refresher Content  

The ionic refresher content is the child component of the <ion-refresher> component that includes the text, icon, and spinner to show during a pull-to-refresh. The ionic gives the pulling icon and the refreshing spinner based on the various platforms. There are many properties used in the ionic refresher content that are as follows:

  • pullingIcon
  • pullingText
  • refreshingSpinner
  • refreshingText

Example: This example explains how you can use the refresher in the ionic application.

Home.page.html

Here, you are required to add the <ion-refresher> component where you call the refresh event. To contain the custom properties, you need to add the <ion-refresher-content> component inside the <ion-refresher> component. 

<ion-header>  
   <ion-toolbar color="primary">  
     <ion-title>Ionic Refresher</ion-title>  
   </ion-toolbar>  
 </ion-header>   
 <ion-content class="ion-padding" color="light">  
   <ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">  
     <ion-refresher-content  
     pullingIcon="arrow-down"  
     pullingText="Pull to refresh"  
     refreshingSpinner="bubbles"  
     refreshingText="Refreshing....."></ion-refresher-content>  
   </ion-refresher>  
 </ion-content>   

Home.page.ts

import { Component } from
'@angular/core';  
 @Component({  
   selector: 'app-home',  
   templateUrl: 'home.page.html',  
   styleUrls: ['home.page.scss'],  
 })  
 export class HomePage {   
   constructor() { }  
   doRefresh(event) {  
     console.log('Pull Event Triggered!');  
   }  
 }   

Output: After executing this code, you will get the output, as shown below:

Ionic Refresher

If you scroll down then, it starts refreshing, as shown below:

Ionic Refresher2

Refresher Progress

The refresher progress used the number of values to set the refresher. The number shows how far down the user has pulled the refresher. If the number is 0, then it displays the user has not pulled down the refresher. If the number is one or greater than 1, then it represents that the user has pulled far down the refresher. If the number is less than 1, then the content will return in its actual position.

Example: This example explains how you can use the refresher progress in the ionic application.

Home.page.html 

<ion-header>  
   <ion-toolbar color="primary">  
     <ion-title>Ionic Refresher Example</ion-title>  
   </ion-toolbar>  
 </ion-header>  
 <ion-content class="ion-padding" color="light">  
   <h1>Pull to Refresh</h1>  
   <ion-refresher slot ="fixed" disabled="false" (ionRefresh)="doRefresh($event)" pullFactor="0.5" pullMin="100" pullMax="200">  
     <ion-refresher-content  
     pullingIcon="arrow-down"  
     pullingText="Pull to refresh"  
     refreshingSpinner="bubbles"  
     refreshingText="Refreshing....."></ion-refresher-content>   
   </ion-refresher>  
   <ion-list>    
     <ion-item *ngFor="let item of dummyList; let i=index">    
       Item {{ i+1 }}  
     </ion-item>    
   </ion-list>  
 </ion-content>   

Home.page.ts

import { Component } from
'@angular/core';  
 @Component({  
   selector: 'app-home',  
   templateUrl: 'home.page.html',  
   styleUrls: ['home.page.scss'],  
 })  
 export class HomePage {   
   constructor() { }  
   doRefresh(event) {  
     console.log('Pull Event Triggered!');  
     setTimeout(() => {
       this.dummyList = Array(5);
       event.target.complete();
     }, 1500); 
   }  
 }   

Output: After executing this code you will get the output, which is shown below:

Ionic Refresher3

Here, pull down or drag the pointer in the content area, then the following screen comes. After scrolling or drag down the pointer, it refreshes the current page and display the new content on the screen.

Ionic Refresher4

Related Topics

Ionic vs Xamarin

Ionic vs Xamarin Ionic and Xamarin are both the most popular frameworks used to develop a hybrid mobile application. Both frameworks are used in large enterprises by the developers. Here, we will discuss the...

4 minutes read.

Ionic progress bar

The ionic progress bar element is a horizontal progress bar used to visualize the progression of operation and activity. You can use the <ion-progress-bar> component to create a progress bar in the ionic...

4 minutes read.

Ionic Geolocation

In today’s time, the mobile location plays an essential role in the mobile application. The Ionic Cordova geolocation plugin provides information about the location of the device, like as latitude and longitude. The...

5 minutes read.

Ionic Slides

The ionic slides component is the multi-section container. You can swipe or drag any segment between them. This contains any number of slides components. Slides help it easy to make galleries, tutorials, and...

2 minutes read.

Ionic Input

Ionic Input Inputs are necessary to collect and process user inputs securely. To be easy for users to communicate, they must follow the process and communication guidelines for each platform. It is a...

3 minutes read.

Ionic vs PhoneGap

Ionic Vs PhoneGap Ionic and PhoneGap are both used to develop the mobile application. Both Frameworks are used in large enterprises by the developers. Here, we are going to compare the important differences between ionic...

3 minutes read.

Ionic Alert

Ionic Alert An Alert is a dialog box that presents the users with important information, or it stores the data from the user by using the inputs. Alerts are a great way to provide...

5 minutes read.

Ionic Cards

Ionic Cards: Ionic cards are a standard part of the user interface that acts as an entry point for more specific information. These are the best components for displaying information...

4 minutes read.

Ionic Checkbox

Ionic Checkbox Ionic Checkbox is nearly the same as a toggle. It can be placed in an ionic element or used as a separate checkbox. It is designed differently for every platform, such...

2 minutes read.

Ionic Grid

The Ionic grid is a very powerful mobile-first flexbox system for building the custom layouts. It is a CSS feature supported by all devices that ionic supports. The Ionic grid is composed of...

11 minutes read.

Ionic Refresher

Refresher means updating the currently showing page so that the user can see the latest view. It is also known as re-loading in web technology. It provides a pull- to-refresh feature on a...

4 minutes read.

Ionic Navigation and Routing

The latest version (ionic 4) of the ionic framework, no longer limited to the angular. In Ionic 4, you can create an ionic project in different front-end frameworks such as Vue.js, React.js, and...

6 minutes read.

Ionic framework Installation

Installation of Ionic Before proceeding with the ionic application, you'll need to install node.js and NPM (Node Package Manager), the code editor, and Ionic CLI. Installation of node.js and NPM These are the primary...

5 minutes read.

Ionic-fab Button

Ionic-fab Button The Ionic FABs (Floating Action Buttons) are standard material design compounds. It is a container element that contains one or more fab buttons. They are required to be placed in a fixed position,...

2 minutes read.

Ionic Actionsheet

Ionic Actionsheet The Action sheet is a dialog box that displays a group of options. It is shown on the top of the application content and must be dismissed manually before the user can resume...

3 minutes read.

Ionic Buttons

Ionic Buttons There are different types of buttons in the Ionic framework. These buttons are subtly animated, enhancing the user experience when using the application. Buttons are a fundamental way of interacting and navigating...

4 minutes read.

Ionic Tutorial for Beginners

What is Ionic? Ionic is an open-source framework that is used for the development of mobile applications. It is also used to build android applications, iOS, applications, desktop applications, and web applications using web...

4 minutes read.

Ionic Select

The Ion Selection component is similar to the HTML <select> element. However, the Ionic Selection component makes it easy for users to categorize and choose the preferred option or other options. You must...

3 minutes read.

Ionic Loading

The ionic loader is an overlay that can be used to indicate activity, the user interaction while blocking. The ionic loader shows on the top of the app content, and it can...

5 minutes read.

Ionic Infinite Scroll

The infinite scroll permits you to perform an action when the user scrolls a particular content from the bottom or top of the page. When you display the large collection of data...

3 minutes read.