Ionic - JavaScript Platform

Angular offers a way to recognize the platform and to configure it. The service for this is $ionicPlatform. It contains various methods for managing configuration. We will show all of them in the following table.

Methods for $ionicPlatform()

Method Parameter Type Details
onHardwareBackButton(parameter) callback function Used for binding to hardware back button.
offHardwareBackButton(parameter) callback function Used for removing the hardware back button.
registerBackButtonAction(parameter1, parameter2, parameter3) callback, priority, actionId function, number, * callback is function that is called when back button is pressed. priority will set a priority since only the action with the highest priority will be executed. actionId can be assigned to the action. Random id will be set if it is not assigned
on(parameter1, parameter2) type, callback string, function type is used to set event for the action. callback is function that will be executed when event occurs.
ready(parameter) callback function Returns the promise object which is resolved when device is ready.

If you open app.js file, you can see how these methods can be used in your app. Following code snippet is from default Ionic configuration. You can see usage case of the ready method.

.run(function($ionicPlatform) {

   $ionicPlatform.ready(function() {
      // Hide the accessory bar by default (remove this to show the 
         accessory bar above the keyboard for form inputs)
      if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
      if (window.StatusBar) {
         // org.apache.cordova.statusbar required
Kickstart Your Career

Get certified by completing the course

Get Started