Ionic Platform
$ionicPlatform
$ionicPlatform is used to detect the current platform, as well as things like overriding the Android back button in PhoneGap/Cordova.
Methods
onHardwareBackButton(callback)
Platforms that have a hardware back button can use this method to bind to it.
| Parameters | Type | Details |
|---|---|---|
| callback |
function
|
Triggers the callback function when this event occurs. |
offHardwareBackButton(callback)
Remove the listener event for the back button.
| Parameters | Type | Details |
|---|---|---|
| callback |
function
|
The originally bound handler function. |
registerBackButtonAction(callback, priority, [actionId])
Registers a hardware back button action. When the button is clicked, only one action will execute, so this method determines that the registered back button action has the highest priority.
For example, if an action sheet is already displayed, the back button should close the action sheet rather than navigate back a page view or close an opened modal.
| Parameters | Type | Details |
|---|---|---|
| callback |
function
|
Triggered when the back button is clicked, if this handler has the highest priority. |
| priority |
number
|
Only the one with the highest priority will execute. |
|
actionId
(optional)
|
*
|
This id specifies this action. Default: a random and unique id. |
Return value:Function. A function that, when called, will unregister the backButtonAction.
ready([callback])
Triggers a callback function when the device is ready.
| Parameters | Type | Details |
|---|---|---|
|
callback
(optional)
|
function=
|
The function to be triggered. |
Returns: a promise object, which is resolved after the object is successfully constructed.
Other Extensions