ons-select

Select component. If you want to place a select with an ID of my-id on a page, use <ons-select select-id="my-id">. The component will automatically display as a Material Design select on Android. Most attributes that can be used for a normal <select> element can also be used on the <ons-select> element.

Tutorial

Select input

The <ons-select> element is used to display a select box with an arbitrary number of options.

There are several attributes that can be used to customize the behavior of the element. These are the same attributes as those that can be used for the regular HTML <select> element.

If you want to place a select with an ID of my-id on a page, use <ons-select select-id="my-id">.

Please check the Onsen UI Reference documentation for a complete reference of the enabled attributes.

Getting the value

ons-select can be combined with ng-model in order to bind its value with a scope variable.

See also

Name Type Description
autofocus Boolean
false
Element automatically gains focus on page load. Optional.
disabled Boolean
false
Specify if select input should be disabled. Optional.
form String Associate a select element to an existing form on the page, even if not nested. Optional.
multiple Boolean
false
If this attribute is defined, multiple options can be selected at once. Optional.
name String Name the select element, useful for instance if it is part of a form. Optional.
required Boolean Make the select input required for submitting the form it is part of. Optional.
select-id String ID given to the inner select, useful for dynamic manipulation. Optional.
size Number
1
How many options are displayed; if there are more than the size then a scroll appears to navigate them. Optional.
Name Description
length Number of options in the select box.
options Several options for handling the select DOM object.
selectedIndex Index of the currently selected option.
value Value of the currently selected option.
Name Description
material Displays a Material Design select input.
underbar Displays a horizontal line underneath a select input.
Signature Description
on(eventName, listener) Add an event listener.
once(eventName, listener) Add an event listener that’s only triggered once.
off(eventName, [listener]) Remove an event listener. If the listener is not specified all listeners for the event type will be removed.
on(eventName, listener)

Add an event listener.

Parameters
Name Type Description
eventName String Name of the event.
listener Function Function to execute when the event is triggered.
once(eventName, listener)

Add an event listener that’s only triggered once.

Parameters
Name Type Description
eventName String Name of the event.
listener Function Function to execute when the event is triggered.
off(eventName, [listener])

Remove an event listener. If the listener is not specified all listeners for the event type will be removed.

Parameters
Name Type Description
eventName String Name of the event.
listener Function Function to execute when the event is triggered.

Need Help?

If you have any questions, use our Community Forum or talk to us on Discord chat. The Onsen UI team and your peers in the community will work together to help solve your issues.

For bug reports and feature requests use our GitHub Issues page.