ons

A global object that's used in Onsen UI. This object can be reached from the AngularJS scope.

Methods Summary #

Signature Description
ready(callback) Method used to wait for app initialization. The callback will not be executed until Onsen UI has been completely initialized.
bootstrap([moduleName, [dependencies]]) Initialize Onsen UI. Can be used to load Onsen UI without using the ng-app attribute from AngularJS.
enableAutoStatusBarFill() Enable status bar fill feature on iOS7 and above.
disableAutoStatusBarFill() Disable status bar fill feature on iOS7 and above.
findParentComponentUntil(name, [dom]) Find parent component object of dom element.
findComponent(selector, [dom]) Find component object using CSS selector.
setDefaultDeviceBackButtonListener(listener) Set default handler for device back button.
disableDeviceBackButtonHandler() Disable device back button event handler.
enableDeviceBackButtonHandler() Enable device back button event handler.
isReady() Returns true if Onsen UI is initialized.
compile(dom) Compile Onsen UI components.
isWebView() Returns true if running inside Cordova.
createAlertDialog(page, [options]) Create a alert dialog instance from a template.
createDialog(page, [options]) Create a dialog instance from a template.
createPopover(page, [options]) Create a popover instance from a template.

Methods

ready(callback) #

Method used to wait for app initialization. The callback will not be executed until Onsen UI has been completely initialized.

Parameters
Name Type Description
callback Function Function that executes after Onsen UI has been initialized.

bootstrap([moduleName, [dependencies]]): Object #

Initialize Onsen UI. Can be used to load Onsen UI without using the ng-app attribute from AngularJS.

Returns: An AngularJS module object.

Parameters
Name Type Description
moduleName String AngularJS module name.
dependencies Array List of AngularJS module dependencies.

enableAutoStatusBarFill() #

Enable status bar fill feature on iOS7 and above.

disableAutoStatusBarFill() #

Disable status bar fill feature on iOS7 and above.

findParentComponentUntil(name, [dom]): Object #

Find parent component object of dom element.

Returns: Component object. Will return null if no component was found.

Parameters
Name Type Description
name String Name of component, i.e. 'ons-page'.
dom Object|jqLite|HTMLElement $event, jqLite or HTMLElement object.

findComponent(selector, [dom]): Object #

Find component object using CSS selector.

Returns: Component object. Will return null if no component was found.

Parameters
Name Type Description
selector String CSS selector
dom HTMLElement DOM element to search from.

setDefaultDeviceBackButtonListener(listener) #

Set default handler for device back button.

Parameters
Name Type Description
listener Function Function that executes when device back button is pressed.

disableDeviceBackButtonHandler() #

Disable device back button event handler.

enableDeviceBackButtonHandler() #

Enable device back button event handler.

isReady(): Boolean #

Returns true if Onsen UI is initialized.

Returns: Will be true if Onsen UI is initialized.

compile(dom) #

Compile Onsen UI components.

Parameters
Name Type Description
dom HTMLElement Element to compile.

isWebView(): Boolean #

Returns true if running inside Cordova.

Returns: Will be true if the app is running in Cordova.

createAlertDialog(page, [options]): Promise #

Create a alert dialog instance from a template.

Returns: Promise object that resolves to the alert dialog component object.

Parameters
Name Type Description
page String Page name. Can be either an HTML file or an containing a component.
options Object Parameter object.
options.parentScope Object Parent scope of the dialog. Used to bind models and access scope methods from the dialog.

createDialog(page, [options]): Promise #

Create a dialog instance from a template.

Returns: Promise object that resolves to the dialog component object.

Parameters
Name Type Description
page String Page name. Can be either an HTML file or an containing a component.
options Object Parameter object.
options.parentScope Object Parent scope of the dialog. Used to bind models and access scope methods from the dialog.

createPopover(page, [options]): Promise #

Create a popover instance from a template.

Returns: Promise object that resolves to the popover component object.

Parameters
Name Type Description
page String Page name. Can be either an HTML file or an containing a component.
options Object Parameter object.
options.parentScope Object Parent scope of the dialog. Used to bind models and access scope methods from the dialog.

Discussion #