×

Ionic Contents

Ionic Contents

The content component provides an easy-to-use content area with some useful ways to control the scrollable region. There should be only one content in one view.

Content, along with several other Ionic elements, can be optimized to modify its padding, margin, and more by using the global styles given in the CSS Utilities or by styling them individually using the CSS and the available CSS Custom Properties.

Almost every mobile application contains some essential elements. Typically, these items include a header and footer that will cover the top and bottom of the screen. All other elements will be placed between these two. Ionic provides an element of ion-content that acts as a container that will wrap all the other elements we want to create. The given below example shows the ionic content in the Ionic application.

Example:

 
   
   
  Ionic Content 
   
   
   
   
  

Python is a general-purpose programming language with a high level of interpretation. The Python design philosophy, created by Guido Van Rossum and first launched in 1991, emphasizes the ease of reading the code with its remarkable use of essential spaces.

Python is written dynamically, and garbage is collected. It is compatible with multiple programming models, including procedural, object-oriented, and functional programming.

Output: When you run the given code, then you will get this output, which is shown in the screenshot.

Ionic Contents

Ionic Content Scrolling: Many types of scrolling are used in the ion-content component. Ion-Content-Scrolling is used to scroll the screen top to bottom and bottom to top with the help of the scroll button. If you want to use the ionic content scroll, then you require to enable the scroll event by setting the [scrollEvents] = "true."

  • IonScrollStart: It used when the scroll started.
  • IonScrollEnd: It used when the scroll ended. 

Example: This example shows how you can include the scroll button in the ionic content.

Home.page.html

 
   
   
  Content Scroll 
   
   
   
   
   
  Scroll To Bottom 
   
    
   
  {{ item.value }} 
   
   
   
  Scroll To Top 
   
    

Home.page.ts

import { Component, ViewChild } from '@angular/core'; 
 import { IonContent, } from '@ionic/angular'; 
 @Component({ 
  selector: 'app-home', 
  templateUrl: 'home.page.html', 
  styleUrls: ['home.page.scss'], 
 }) 
 export class HomePage { 
  @ViewChild(IonContent, {static: false}) content: IonContent;  
  dummyList: any; 
  constructor( 
  ) { 
  this.dummyList = [ 
  { 
  value: 'Item 0',  
  }, { 
  value: 'Item 1', 
  }, { 
  value: 'Item 2', 
  }, { 
  value: 'Item 4', 
  }, { 
  value: 'Subjects', 
  }, { 
  value: 'Fruites', 
  }, { 
  value: 'Cake', 
  }, { 
  value: 'Colddrink', 
  }, { 
  value: 'Sweets', 
  }, { 
  value: 'Food', 
  }, { 
  value: 'Movie', 
  }, { 
  value: 'Songs', 
  }, { 
  value: 'Games',  
  }, { 
  value: 'Phones', 
  }, { 
  value: 'Market', 
  }, { 
  value: 'Train', 
  }, { 
  value: 'College',  
  }, { 
  value: 'Dish', 
  }, { 
  value: 'City', 
  }, { 
  value: 'Country', 
  }, {  
  value: 'Travells', 
  }
  ]; 
  } 
  logScrollStart() { 
  console.log('logScrollStart : Scroll Starts'); 
  } 
  logScrolling() {  
  console.log('logScrolling : Scrolling'); 
  } 
  logScrollEnd() { 
  console.log('logScrollEnd : Scroll Ends'); 
  } 
  ScrollToBottom() { 
  this.content.scrollToBottom(800); 
  } 
  ScrollToTop() { 
  this.content.scrollToTop(800); 
  } 
  }  

Output: When you run the given code, then you will get this output, which is shown in the screenshot.

Ionic Contents2

When you click on the Scroll to Bottom button, then it scrolls down the page, and if you click on the Scroll to Top Button, then it goes up. The given screenshot shows the output.

When you click on the Scroll to Bottom button

Related Topics

Ionic Camera

Hybrid mobile applications can make very quickly, but sometimes it becomes a challenge to get the features that access the hardware such as GPS, storage, file storage, cameras, and networks. Cordova offers plugins...

4 minutes read.

Ionic Range

The Range slider lets users choose from a range of values by moving the slider knob. You can accept two knobs, but by default, one-knob controls the range value. Range labels You can put down on...

2 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 Radio

Ionic Radio The radio button is the type of input component that has a Boolean value. The Ionic radio button has a different pattern on every platform, as well as other Ionic components....

2 minutes read.

Ionic Modal

Ionic modal is displayed as a temporary UI that slides into the screen. The ionic modal is a dialog box that is displayed at the top of the app’s content, and it...

5 minutes read.

Ionic Splash Screen

The Apache Cordova plugin helps to displays and hides a splash screen during the application launch. The Ionic Splash Screen is similar to a home page on a website. The ionic splash...

2 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 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.

History of Ionic

It is a complete open-source platform for hybrid mobile application development created by Ben Sperry, Max Lynch, and Adam Bradley of Drifty Co. in 2013. The first alpha version of the framework was...

2 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.

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 Reorder

The Ionic offers the <ion-reorder> component to reordering features. Ionic reorder component adds the Drag and Drop feature to list items, in which the user can change the order of the items. Reorder...

3 minutes read.

Features of Ionic Framework

The Ionic Framework is based on the AngularJS framework that permits a programmer to use a combination of many other programming languages, like HTML5, CSS, and JavaScript. Some of the...

4 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 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 vs Apache Cordova

Ionic Vs Apache Cordova Ionic and Cordova are two popular technology going on in the market for mobile application development. The combination of these two technologies creates a development platform that is known as...

3 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 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 Colors

Ionic Colors Before we start with the actual elements available in the Ionic frame, let's understand a little bit how Ionic uses colors for different elements. Ionic Color Classes Ionic framework is a set of nine predefined...

3 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.