Conditionally display content depending on the platform, device orientation or both.
Sometimes it is useful to conditionally hide or show certain components based on platform. When running on iOS the <ons-if>
element can be used to hide the <ons-fab>
element.
<ons-if>
will let you filter the content of your app depending on some variables:
platform
attribute: allows or removes content depending on the running platform. Possible values are ios
, android
, windows
and other
. Normally you will include an android
condition and a ios other
condition.orientation
attribute: Possible values are landscape
and portrait
. Unlike the platform, this attribute is dynamic so it refreshes the view when changing the orientation.In AngularJS this element can be substituted by the more powerful ng-if
, ng-switch
, ng-show
or ng-hide
directives. Use ons.platform
and ons.orientation
methods to achieve a similar result.
Name | Type | Description |
---|---|---|
platform | string |
Space-separated platform names. Possible values are "ios" , "android" , "windows" and "other" .
Optional.
Works only during initialization.
|
orientation | string |
Either "portrait" or "landscape" .
Optional.
|
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.