ionic-angular
- Version 3.9.10
- Published
- 19.6 MB
- No dependencies
- MIT license
Install
npm i ionic-angular
yarn add ionic-angular
pnpm add ionic-angular
Overview
A powerful framework for building mobile and progressive web apps with JavaScript and Angular
Index
Variables
Functions
Classes
Animation
- add()
- afterAddClass()
- afterClearStyles()
- afterRemoveClass()
- afterStyles()
- beforeAddClass()
- beforeAddRead()
- beforeAddWrite()
- beforeClearStyles()
- beforeRemoveClass()
- beforeStyles()
- destroy()
- duration()
- easing()
- easingReverse()
- element()
- from()
- fromTo()
- getDuration()
- getEasing()
- hasChildren
- hasCompleted
- isPlaying
- isRoot()
- onFinish()
- opts
- parent
- play()
- plt
- progressEnd()
- progressStart()
- progressStep()
- reverse()
- stop()
- syncPlay()
- to()
App
- getActiveNav()
- getActiveNavContainers()
- getActiveNavs()
- getNavByIdOrName()
- getRootNav()
- getRootNavById()
- getRootNavs()
- goBack()
- isEnabled()
- isScrolling()
- navPop()
- present()
- registerRootNav()
- setElementClass()
- setEnabled()
- setScrolling()
- setTitle()
- unregisterRootNav()
- viewDidEnter
- viewDidLeave
- viewDidLoad
- viewWillEnter
- viewWillLeave
- viewWillUnload
Content
- addImg()
- addScrollPadding()
- clearScrollPaddingFocusOut()
- contentBottom
- contentHeight
- contentTop
- contentWidth
- directionX
- directionY
- enableJsScroll()
- fullscreen
- getContentDimensions()
- getFixedElement()
- getScrollElement()
- imgsUpdate()
- ionScroll
- ionScrollEnd
- ionScrollStart
- isImgsUpdatable()
- isScrolling
- ngAfterViewInit()
- ngOnDestroy()
- onScrollElementTransitionEnd()
- removeImg()
- resize()
- scrollDownOnLoad
- scrollHeight
- scrollLeft
- scrollTo()
- scrollToBottom()
- scrollTop
- scrollToTop()
- scrollWidth
- setScrollElementStyle()
- statusbarPadding
DateTime
- calcMinMax()
- cancelText
- dayNames
- dayShortNames
- dayValues
- displayFormat
- divyColumns()
- doneText
- generate()
- getDefaultValueDateString()
- getValue()
- getValueOrDefault()
- hasValue()
- hourValues
- initialValue
- ionCancel
- max
- min
- minuteValues
- monthNames
- monthShortNames
- monthValues
- ngAfterContentInit()
- open()
- pickerFormat
- pickerOptions
- placeholder
- updateText()
- validate()
- validateColumn()
- yearValues
Menu
- backdrop
- canSwipe()
- close()
- content
- enable()
- enabled
- getBackdropElement()
- getContentElement()
- getElementRef()
- getMenuController()
- getMenuElement()
- getNativeElement()
- id
- ionClose
- ionDrag
- ionOpen
- isAnimating()
- isOpen
- isRightSide
- maxEdgeStart
- menuContent
- menuNav
- ngOnDestroy()
- ngOnInit()
- onBackdropClick()
- open()
- persistent
- resize()
- setElementAttribute()
- setElementClass()
- setOpen()
- side
- swipeEnable()
- swipeEnabled
- toggle()
- type
- width()
NavController
- canGoBack()
- canSwipeBack()
- config
- first()
- getActive()
- getActiveChildNav()
- getActiveChildNavs()
- getAllChildNavs()
- getByIndex()
- getPrevious()
- getSecondaryIdentifier()
- getType()
- getViews()
- goToRoot()
- id
- indexOf()
- insert()
- insertPages()
- isActive()
- isTransitioning()
- last()
- length()
- name
- parent
- pop()
- popAll()
- popTo()
- popToRoot()
- push()
- registerChildNav()
- remove()
- removeView()
- resize()
- setPages()
- setRoot()
- swipeBackEnabled
- viewDidEnter
- viewDidLeave
- viewDidLoad
- viewWillEnter
- viewWillLeave
- viewWillUnload
NavControllerBase
- canGoBack()
- canSwipeBack()
- config
- destroy()
- dismissPageChangeViews()
- first()
- getActive()
- getActiveChildNav()
- getActiveChildNavs()
- getAllChildNavs()
- getByIndex()
- getPrevious()
- getSecondaryIdentifier()
- getType()
- getViewById()
- getViews()
- goToRoot()
- hasChildren()
- id
- indexOf()
- insert()
- insertPages()
- isActive()
- isSwipeBackEnabled()
- isTransitioning()
- last()
- length()
- name
- parent
- plt
- pop()
- popAll()
- popTo()
- popToRoot()
- push()
- registerChildNav()
- remove()
- removeView()
- resize()
- setPages()
- setRoot()
- setTransitioning()
- setViewport()
- swipeBackEnabled
- swipeBackEnd()
- swipeBackProgress()
- swipeBackStart()
- unregisterChildNav()
- viewDidEnter
- viewDidLeave
- viewDidLoad
- viewWillEnter
- viewWillLeave
- viewWillUnload
Platform
- backButton
- cancelRaf()
- cancelTimeout()
- dir()
- doc()
- exitApp()
- focusOutActiveElement()
- getActiveElement()
- getElementBoundingClientRect()
- getElementComputedStyle()
- getElementFromPoint()
- getPlatformConfig()
- getQueryParam()
- hasFocus()
- hasFocusedTextInput()
- height()
- init()
- is()
- isActiveElement()
- isLandscape()
- isPlatformMatch()
- isPortrait()
- isRTL
- lang()
- matchUserAgentVersion()
- navigatorPlatform()
- pause
- platforms()
- prepareReady()
- raf()
- ready()
- registerBackButtonAction()
- registerListener()
- registry()
- resize
- resume
- runBackButtonAction()
- setCssProps()
- setDefault()
- setDir()
- setDocument()
- setLang()
- setNavigatorPlatform()
- setPlatformConfigs()
- setQueryParams()
- setUserAgent()
- setWindow()
- setZone()
- testNavigatorPlatform()
- testQuery()
- testUserAgent()
- timeout()
- transitionEnd()
- triggerReady()
- url()
- userAgent()
- version()
- versions()
- width()
- win()
- windowLoad()
- zone
Slides
- autoHeight
- autoplay
- autoplayDisableOnInteraction
- autoplayStopOnLast
- centeredSlides
- clickedIndex
- clickedSlide
- container
- control
- controlBy
- controlInverse
- coverflow
- cube
- dir
- direction
- effect
- enableKeyboardControl()
- fade
- firstSlideMessage
- flip
- followFinger
- freeMode
- freeModeMinimumVelocity
- freeModeMomentum
- freeModeMomentumBounce
- freeModeMomentumBounceRatio
- freeModeMomentumRatio
- freeModeMomentumVelocityRatio
- freeModeSticky
- getActiveIndex()
- getPreviousIndex()
- height
- id
- initialSlide
- ionSlideAutoplay
- ionSlideAutoplayStart
- ionSlideAutoplayStop
- ionSlideDidChange
- ionSlideDoubleTap
- ionSlideDrag
- ionSlideNextEnd
- ionSlideNextStart
- ionSlidePrevEnd
- ionSlidePrevStart
- ionSlideProgress
- ionSlideReachEnd
- ionSlideReachStart
- ionSlideTap
- ionSlideTouchEnd
- ionSlideTouchStart
- ionSlideTransitionEnd
- ionSlideTransitionStart
- ionSlideWillChange
- iOSEdgeSwipeDetection
- iOSEdgeSwipeThreshold
- isBeginning()
- isEnd()
- keyboardControl
- lastSlideMessage
- length()
- lockSwipes()
- lockSwipeToNext()
- lockSwipeToPrev()
- longSwipes
- longSwipesMs
- longSwipesRatio
- loop
- loopAdditionalSlides
- loopedSlides
- nextButton
- nextSlideMessage
- ngAfterContentInit()
- ngOnDestroy()
- noSwiping
- onlyExternal
- originalEvent
- pager
- paginationBulletRender
- paginationClickable
- paginationHide
- paginationType
- parallax
- prevButton
- preventClicks
- preventClicksPropagation
- prevSlideMessage
- progress
- realIndex
- renderedHeight
- renderedWidth
- resistance
- resistanceRatio
- resize()
- roundLengths
- runCallbacksOnInit
- setWrapperSize
- shortSwipes
- simulateTouch
- slideId
- slideNext()
- slidePrev()
- slidesOffsetAfter
- slidesOffsetBefore
- slidesPerColumn
- slidesPerColumnFill
- slidesPerGroup
- slidesPerView
- slideTo()
- slideToClickedSlide
- spaceBetween
- speed
- startAutoplay()
- stopAutoplay()
- swipeDirection
- swipeHandler
- threshold
- touchAngle
- touchEventsTarget
- touchMoveStopPropagation
- touchRatio
- touchReleaseOnEdges
- update()
- velocity
- virtualTranslate
- watchSlidesProgress
- watchSlidesVisibility
- width
- zoom
- zoomMax
- zoomMin
- zoomToggle
ViewController
- component
- contentRef()
- data
- didEnter
- didLeave
- dismiss()
- emit()
- enableBack()
- getContent()
- getFooter()
- getHeader()
- getIONContent()
- getIONContentRef()
- getNav()
- getNavbar()
- getNavParams()
- getTransitionName()
- getZIndex()
- handleOrientationChange()
- hasNavbar()
- id
- index
- init()
- instance
- isFirst()
- isLast()
- isOverlay
- name
- onDidDismiss()
- onWillDismiss()
- pageRef()
- readReady
- setBackButtonText()
- setLeavingOpts()
- showBackButton()
- subscribe()
- willEnter
- willLeave
- willUnload
- writeReady
VirtualScroll
- approxFooterHeight
- approxFooterWidth
- approxHeaderHeight
- approxHeaderWidth
- approxItemHeight
- approxItemWidth
- bufferRatio
- firstRecord()
- footerFn
- headerFn
- lastRecord()
- ngAfterContentInit()
- ngDoCheck()
- ngOnChanges()
- ngOnDestroy()
- readUpdate()
- renderVirtual()
- resize()
- scrollEnd()
- scrollUpdate()
- setElementClass()
- virtualScroll
- virtualTrackBy
- writeUpdate()
Interfaces
Type Aliases
Variables
variable BLOCK_ALL
const BLOCK_ALL: BlockerOptions;
variable ConfigToken
const ConfigToken: InjectionToken<any>;
variable DeepLinkConfigToken
const DeepLinkConfigToken: InjectionToken<any>;
variable DeepLinkMetadataFactory
var DeepLinkMetadataFactory: DeepLinkMetadataFactory;
variable GESTURE_GO_BACK_SWIPE
const GESTURE_GO_BACK_SWIPE: string;
variable GESTURE_ITEM_SWIPE
const GESTURE_ITEM_SWIPE: string;
variable GESTURE_MENU_SWIPE
const GESTURE_MENU_SWIPE: string;
variable GESTURE_REFRESHER
const GESTURE_REFRESHER: string;
variable GESTURE_TOGGLE
const GESTURE_TOGGLE: string;
variable PlatformConfigToken
const PlatformConfigToken: InjectionToken<any>;
Functions
function IonicPage
IonicPage: (_config?: IonicPageMetadata) => ClassDecorator;
IonicPage The Ionic Page handles registering and displaying specific pages based on URLs. It's used underneath
NavController
so it will never have to be interacted with directly. When a new page is pushed withNavController
, the URL is updated to match the path to this page.Unlike traditional web apps, URLs don't dictate navigation in Ionic apps. Instead, URLs help us link to specific pieces of content as a breadcrumb. The current URL gets updated as we navigate, but we use the
NavController
push and pop, orNavPush
andNavPop
to move around. This makes it much easier to handle complicated nested navigation.We refer to our URL system as a deep link system instead of a router to encourage Ionic developers to think of URLs as a breadcrumb rather than as the source of truth in navigation. This encourages flexible navigation design and happy apps all over the world.
The first step to setting up deep links is to add the page that should be a deep link in the
IonicPageModule.forChild
import of the page's module. For our examples, this will beMyPage
:@NgModule({declarations: [MyPage],imports: [IonicPageModule.forChild(MyPage)],entryComponents: [MyPage]})export class MyPageModule {}Then, add the
@IonicPage
decorator to the component. The most simple usage is adding an empty decorator:@IonicPage()@Component({templateUrl: 'main.html'})export class MyPage {}This will automatically create a link to the
MyPage
component using the same name as the class,name
:'MyPage'
. The page can now be navigated to by using this name. For example:@Component({templateUrl: 'another-page.html'})export class AnotherPage {constructor(public navCtrl: NavController) {}goToMyPage() {// go to the MyPage componentthis.navCtrl.push('MyPage');}}The
@IonicPage
decorator accepts aDeepLinkMetadataType
object. This object accepts the following properties:name
,segment
,defaultHistory
, andpriority
. All of them are optional but can be used to create complex navigation links. Thename
andsegment
values must be unique.### Changing Name
As mentioned previously, the
name
property will be set to the class name if it isn't provided. Changing the name of the link is extremely simple. To change the name used to link to the component, simply pass it in the decorator like so:@IonicPage({name: 'my-page'})This will create a link to the
MyPage
component using the name'my-page'
. Similar to the previous example, the page can be navigated to by using the name:goToMyPage() {// go to the MyPage componentthis.navCtrl.push('my-page');}### Setting URL Path
The
segment
property is used to set the URL to the page. If this property isn't provided, thesegment
will use the value of source file name without the extension ('my-page.ts'
results in segment name'my-page'
). Since components can be loaded anywhere in the app, thesegment
doesn't require a full URL path. When a page becomes the active page, thesegment
is appended to the URL.The
segment
can be changed to anything and doesn't have to match thename
. For example, passing a value forname
andsegment
:@IonicPage({name: 'my-page',segment: 'some-path'})When navigating to this page as the first page in the app, the URL will look something like:
http://localhost:8101/#/some-pathHowever, navigating to the page will still use the
name
like the previous examples do.### Dynamic Links
The
segment
property is useful for creating dynamic links. Sometimes the URL isn't known ahead of time, so it can be passed as a variable.Since passing data around is common practice in an app, it can be reflected in the app's URL by using the
:param
syntax. For example, set thesegment
in the@IonicPage
decorator:@IonicPage({name: 'detail-page',segment: 'detail/:id'})In this case, when we
push
to a new instance of'detail-page'
, the value ofid
will in thedetailInfo
data being passed topush
will replace:id
in the URL.Important: The property needs to be something that can be converted into a string, objects are not supported.
For example, to push the
'detail-page'
in theListPage
component, the following code could be used:@IonicPage({name: 'list'})export class ListPage {constructor(public navCtrl: NavController) {}pushPage(detailInfo) {// Push an `id` to the `'detail-page'`this.navCtrl.push('detail-page', {'id': detailInfo.id})}}If the value of
detailInfo.id
is12
, for example, the URL would end up looking like this:http://localhost:8101/#/list/detail/12Since this
id
will be used to pull in the data of the specific detail page, it's Important that theid
is unique.Note: Even though the
name
isdetail-page
, thesegment
usesdetail/:id
, and the URL will use thesegment
.### Default History
Pages can be navigated to using deep links from anywhere in the app, but sometimes the app is launched from a URL and the page needs to have the same history as if it were navigated to from inside of the app.
By default, the page would be navigated to as the first page in the stack with no prior history. A good example is the App Store on iOS. Clicking on a URL to an application in the App Store will load the details of the application with no back button, as if it were the first page ever viewed.
The default history of any page can be set in the
defaultHistory
property. This history will only be used if the history doesn't already exist, meaning if you navigate to the page the history will be the pages that were navigated from.The
defaultHistory
property takes an array of page names. The page names are specified as statically analyzable strings (which means you must use strings and not variables or delared constants). If the parent page does not have aname
specified in itsIonicPage
decorator its name is its class name.For example, setting the history of the detail page to the list page where the
name
islist
:@IonicPage({name: 'detail-page',segment: 'detail/:id',defaultHistory: ['list']})In this example, if the app is launched at
http://localhost:8101/#/detail/my-detail
the displayed page will be the'detail-page'
with an id ofmy-detail
and it will show a back button that goes back to the'list'
page.For a deeper example:
@IonicPage({segment: 'contact-more-info',defaultHistory: ['ContactDetailPage', 'Contact']})...export class ContactMoreInfoPage {...}In this example, if the app is launched at
http://localhost:8101/#/contact/contact-more-info
the displayed page will be the'ContactMoreInfoPage'
. It will show a back button that will go to the'ContactDetailPage'
which will also show a back button which will go to the'Contact'
page.An example of an application with a set history stack is the Instagram application. Opening a link to an image on Instagram will show the details for that image with a back button to the user's profile page. There is no "right" way of setting the history for a page, it is up to the application.
### Priority
The
priority
property is only used during preloading. By default, preloading is turned off so setting this property would do nothing. Preloading eagerly loads all deep links after the application boots instead of on demand as needed. To enable preloading, setpreloadModules
in the main application module config totrue
:@NgModule({declarations: [MyApp],imports: [BrowserModule,IonicModule.forRoot(MyApp, {preloadModules: true})],bootstrap: [IonicApp],entryComponents: [MyApp]})export class AppModule { }If preloading is turned on, it will load the modules based on the value of
priority
. The following values are possible forpriority
:"high"
,"low"
, and"off"
. When there is nopriority
, it will be set to"low"
.All deep links with their priority set to
"high"
will be loaded first. Upon completion of loading the"high"
priority modules, all deep links with a priority of"low"
(or no priority) will be loaded. If the priority is set to"off"
the link will not be preloaded. Setting thepriority
is as simple as passing it to the@IonicPage
decorator:@IonicPage({name: 'my-page',priority: 'high'})We recommend setting the
priority
to"high"
on the pages that will be viewed first when launching the application.
function isActivatable
isActivatable: (ele: HTMLElement) => boolean;
function normalizeURL
normalizeURL: (url: string) => string;
Rewrites an absolute URL so it works across file and http based engines
function provideLocationStrategy
provideLocationStrategy: ( platformLocationStrategy: PlatformLocation, baseHref: string, config: Config) => HashLocationStrategy | PathLocationStrategy;
function registerModeConfigs
registerModeConfigs: (config: Config) => () => void;
function reorderArray
reorderArray: (array: any[], indexes: { from: number; to: number }) => any[];
function setupConfig
setupConfig: (userConfig: any, plt: Platform) => Config;
function setupEvents
setupEvents: (plt: Platform, dom: DomController) => Events;
function setupPlatform
setupPlatform: ( doc: HTMLDocument, platformConfigs: { [key: string]: PlatformConfig }, zone: NgZone) => Platform;
function setupProvideEvents
setupProvideEvents: (plt: Platform, dom: DomController) => () => Events;
function setupTapClick
setupTapClick: ( config: Config, plt: Platform, dom: DomController, app: App, gestureCtrl: GestureController) => () => TapClick;
Classes
class ActionSheet
class ActionSheet extends ViewController {}
constructor
constructor(app: App, opts: ActionSheetOptions, config: Config);
method addButton
addButton: (button: ActionSheetButton | string) => ActionSheet;
Parameter button
Action sheet button
method getTransitionName
getTransitionName: (direction: string) => string;
method present
present: (navOptions?: NavOptions) => Promise<any>;
Present the action sheet instance.
Parameter navOptions
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method setSubTitle
setSubTitle: (subTitle: string) => ActionSheet;
Parameter subTitle
Action sheet subtitle
method setTitle
setTitle: (title: string) => ActionSheet;
Parameter title
Action sheet title
class ActionSheetCmp
class ActionSheetCmp {}
constructor
constructor( _viewCtrl: ViewController, config: Config, _elementRef: ElementRef, gestureCtrl: GestureController, params: NavParams, renderer: Renderer);
property cancelButton
cancelButton: ActionSheetButton;
property d
d: ActionSheetOptions;
property descId
descId: string;
property enabled
enabled: boolean;
property gestureBlocker
gestureBlocker: BlockerDelegate;
property hdrId
hdrId: string;
property id
id: number;
property mode
mode: string;
method bdClick
bdClick: () => void;
method click
click: (button: ActionSheetButton) => void;
method dismiss
dismiss: (role: string) => Promise<any>;
method ionViewDidEnter
ionViewDidEnter: () => void;
method ionViewDidLeave
ionViewDidLeave: () => void;
method ionViewDidLoad
ionViewDidLoad: () => void;
method ionViewWillEnter
ionViewWillEnter: () => void;
method keyUp
keyUp: (ev: KeyboardEvent) => void;
method ngOnDestroy
ngOnDestroy: () => void;
class ActionSheetController
class ActionSheetController {}
ActionSheetController An Action Sheet is a dialog that lets the user choose from a set of options. It appears on top of the app's content, and must be manually dismissed by the user before they can resume interaction with the app. Dangerous (destructive) options are made obvious in
ios
mode. There are easy ways to cancel out of the action sheet, such as tapping the backdrop or hitting the escape key on desktop.An action sheet is created from an array of
buttons
, with each button including properties for itstext
, and optionally ahandler
androle
. If a handler returnsfalse
then the action sheet will not be dismissed. An action sheet can also optionally have atitle
,subTitle
and anicon
.A button's
role
property can either bedestructive
orcancel
. Buttons without a role property will have the default look for the platform. Buttons with thecancel
role will always load as the bottom button, no matter where they are in the array. All other buttons will be displayed in the order they have been added to thebuttons
array. Note: We recommend thatdestructive
buttons are always the first button in the array, making them the top button. Additionally, if the action sheet is dismissed by tapping the backdrop, then it will fire the handler from the button with the cancel role.You can pass all of the action sheet's options in the first argument of the create method:
ActionSheet.create(opts)
. Otherwise the action sheet's instance has methods to add options, likesetTitle()
oraddButton()
.import { ActionSheetController } from 'ionic-angular'export class MyClass{constructor(public actionSheetCtrl: ActionSheetController) { }presentActionSheet() {const actionSheet = this.actionSheetCtrl.create({title: 'Modify your album',buttons: [{text: 'Destructive',role: 'destructive',handler: () => {console.log('Destructive clicked');}},{text: 'Archive',handler: () => {console.log('Archive clicked');}},{text: 'Cancel',role: 'cancel',handler: () => {console.log('Cancel clicked');}}]});actionSheet.present();}}ActionSheet create options
| Option | Type | Description | |-----------------------|------------|--------------------------------------------------------------------| | title |
string
| The title for the Action Sheet. | | subTitle |string
| The sub-title for the Action Sheet. | | cssClass |string
| Additional classes for custom styles, separated by spaces. | | enableBackdropDismiss |boolean
| If the Action Sheet should close when the user taps the backdrop. | | buttons |array<any>
| An array of buttons to display. |ActionSheet button options
| Option | Type | Description | |----------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------| | text |
string
| The buttons text. | | icon |icon
| The buttons icons. | | handler |any
| An express the button should evaluate. | | cssClass |string
| Additional classes for custom styles, separated by spaces. | | role |string
| How the button should be displayed,destructive
orcancel
. If no role is provided, it will display the button without any additional styles. |### Dismissing And Async Navigation
After an action sheet has been dismissed, the app may need to also transition to another page depending on the handler's logic. However, because multiple transitions were fired at roughly the same time, it's difficult for the nav controller to cleanly animate multiple transitions that may have been kicked off asynchronously. This is further described in the [
Nav Transition Promises
](../../nav/NavController/#nav-transition-promises) section. For action sheets, this means it's best to wait for the action sheet to finish its transition out before starting a new transition on the same nav controller.In the example below, after the button has been clicked, its handler waits on async operation to complete, *then* it uses
pop
to navigate back a page in the same stack. The potential problem is that the async operation may have been completed before the action sheet has even finished its transition out. In this case, it's best to ensure the action sheet has finished its transition out first, *then* start the next transition.const actionSheet = this.actionSheetCtrl.create({title: 'Hello',buttons: [{text: 'Ok',handler: () => {// user has clicked the action sheet button// begin the action sheet's dimiss transitionlet navTransition = actionSheet.dismiss();// start some async methodsomeAsyncOperation().then(() => {// once the async operation has completed// then run the next nav transition after the// first transition has finished animating outnavTransition.then(() => {this.nav.pop();});});return false;}}]});actionSheet.present();It's important to note that the handler returns
false
. A feature of button handlers is that they automatically dismiss the action sheet when their button was clicked, however, we'll need more control regarding the transition. Because the handler returnsfalse
, then the action sheet does not automatically dismiss itself. Instead, you now have complete control of when the action sheet has finished transitioning, and the ability to wait for the action sheet to finish transitioning out before starting a new transition./docs/demos/src/action-sheet/
See Also
constructor
constructor(_app: App, config: Config);
property config
config: Config;
method create
create: (opts?: ActionSheetOptions) => ActionSheet;
Open an action sheet with a title, subTitle, and an array of buttons
Parameter opts
Action sheet options
class Alert
class Alert extends ViewController {}
constructor
constructor(app: App, opts: AlertOptions, config: Config);
method addButton
addButton: (button: AlertButton | string) => Alert;
Parameter button
Alert button
method addInput
addInput: (input: AlertInputOptions) => Alert;
Parameter input
Alert input
method getTransitionName
getTransitionName: (direction: string) => string;
method present
present: (navOptions?: NavOptions) => Promise<any>;
Present the alert instance.
Parameter navOptions
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method setCssClass
setCssClass: (cssClass: string) => Alert;
Parameter cssClass
Set the CSS class names on the alert's outer wrapper.
method setMessage
setMessage: (message: string) => Alert;
Parameter message
Alert message content
method setMode
setMode: (mode: string) => void;
Parameter mode
Set the mode of the alert (ios, md, wp).
method setSubTitle
setSubTitle: (subTitle: string) => Alert;
Parameter subTitle
Alert subtitle
method setTitle
setTitle: (title: string) => Alert;
Parameter title
Alert title
class AlertCmp
class AlertCmp {}
constructor
constructor( _viewCtrl: ViewController, _elementRef: ElementRef, config: Config, gestureCtrl: GestureController, params: NavParams, _renderer: Renderer, _plt: Platform);
property activeId
activeId: string;
property d
d: AlertOptions;
property descId
descId: string;
property enabled
enabled: boolean;
property gestureBlocker
gestureBlocker: BlockerDelegate;
property hdrId
hdrId: string;
property id
id: number;
property inputType
inputType: string;
property keyboardResizes
keyboardResizes: boolean;
property lastClick
lastClick: number;
property mode
mode: string;
property msgId
msgId: string;
property subHdrId
subHdrId: string;
method bdClick
bdClick: () => void;
method btnClick
btnClick: (button: any) => void;
method cbClick
cbClick: (checkedInput: any) => void;
method dismiss
dismiss: (role: string) => Promise<any>;
method getValues
getValues: () => any;
method ionViewDidEnter
ionViewDidEnter: () => void;
method ionViewDidLeave
ionViewDidLeave: () => void;
method ionViewDidLoad
ionViewDidLoad: () => void;
method ionViewWillEnter
ionViewWillEnter: () => void;
method keyUp
keyUp: (ev: KeyboardEvent) => void;
method ngOnDestroy
ngOnDestroy: () => void;
method rbClick
rbClick: (checkedInput: any) => void;
class AlertController
class AlertController {}
AlertController An Alert is a dialog that presents users with information or collects information from the user using inputs. An alert appears on top of the app's content, and must be manually dismissed by the user before they can resume interaction with the app. It can also optionally have a
title
,subTitle
andmessage
.You can pass all of the alert's options in the first argument of the create method:
create(opts)
. Otherwise the alert's instance has methods to add options, such assetTitle()
oraddButton()
.### Alert Buttons
In the array of
buttons
, each button includes properties for itstext
, and optionally ahandler
. If a handler returnsfalse
then the alert will not automatically be dismissed when the button is clicked. All buttons will show up in the order they have been added to thebuttons
array, from left to right. Note: The right most button (the last one in the array) is the main button.Optionally, a
role
property can be added to a button, such ascancel
. If acancel
role is on one of the buttons, then if the alert is dismissed by tapping the backdrop, then it will fire the handler from the button with a cancel role.### Alert Inputs
Alerts can also include several different inputs whose data can be passed back to the app. Inputs can be used as a simple way to prompt users for information. Radios, checkboxes and text inputs are all accepted, but they cannot be mixed. For example, an alert could have all radio button inputs, or all checkbox inputs, but the same alert cannot mix radio and checkbox inputs. Do note however, different types of "text"" inputs can be mixed, such as
url
,email
,text
, etc. If you require a complex form UI which doesn't fit within the guidelines of an alert then we recommend building the form within a modal instead.import { AlertController } from 'ionic-angular';constructor(public alertCtrl: AlertController) { }presentAlert() {const alert = this.alertCtrl.create({title: 'Low battery',subTitle: '10% of battery remaining',buttons: ['Dismiss']});alert.onDidDismiss(() => console.log('Alert was dismissed by the user'));alert.present();}presentConfirm() {const alert = this.alertCtrl.create({title: 'Confirm purchase',message: 'Do you want to buy this book?',buttons: [{text: 'Cancel',role: 'cancel',handler: () => {console.log('Cancel clicked');}},{text: 'Buy',handler: () => {console.log('Buy clicked');}}]});alert.onDidDismiss(() => console.log('Alert was dismissed by the user'));alert.present();}presentPrompt() {const alert = this.alertCtrl.create({title: 'Login',inputs: [{name: 'username',placeholder: 'Username'},{name: 'password',placeholder: 'Password',type: 'password'}],buttons: [{text: 'Cancel',role: 'cancel',handler: data => {console.log('Cancel clicked');}},{text: 'Login',handler: data => {if (User.isValid(data.username, data.password)) {// logged in!} else {// invalid loginreturn false;}}}]});alert.present();}Alert options
| Property | Type | Description | |-----------------------|-----------|------------------------------------------------------------------------------| | title |
string
| The title for the alert. | | subTitle |string
| The subtitle for the alert. | | message |string
| The message for the alert. | | cssClass |string
| Additional classes for custom styles, separated by spaces. | | inputs |array
| An array of inputs for the alert. See input options. | | buttons |array
| An array of buttons for the alert. See buttons options. | | enableBackdropDismiss |boolean
| Whether the alert should be dismissed by tapping the backdrop. Default true. |Input options
| Property | Type | Description | |-------------|-----------|-----------------------------------------------------------------| | type |
string
| The type the input should be: text, tel, number, etc. | | name |string
| The name for the input. | | placeholder |string
| The input's placeholder (for textual/numeric inputs) | | value |string
| The input's value. | | label |string
| The input's label (only for radio/checkbox inputs) | | checked |boolean
| Whether or not the input is checked. | | disabled |boolean
| Whether or not the input is disabled. | | id |string
| The input's id. |Button options
| Property | Type | Description | |----------|----------|-----------------------------------------------------------------| | text |
string
| The buttons displayed text. | | handler |any
| Emitted when the button is pressed. | | cssClass |string
| An additional CSS class for the button. | | role |string
| The buttons role, null orcancel
. |### Detecting dismissal
Any dismissal of the alert (including backdrop) can be detected using the method
onDidDismiss(() => {})
.### Dismissing And Async Navigation
After an alert has been dismissed, the app may need to also transition to another page depending on the handler's logic. However, because multiple transitions were fired at roughly the same time, it's difficult for the nav controller to cleanly animate multiple transitions that may have been kicked off asynchronously. This is further described in the [
Nav Transition Promises
](../../nav/NavController) section. For alerts, this means it's best to wait for the alert to finish its transition out before starting a new transition on the same nav controller.In the example below, after the alert button has been clicked, its handler waits on async operation to complete, *then* it uses
pop
to navigate back a page in the same stack. The potential problem is that the async operation may have been completed before the alert has even finished its transition out. In this case, it's best to ensure the alert has finished its transition out first, *then* start the next transition.const alert = this.alertCtrl.create({title: 'Hello',buttons: [{text: 'Ok',handler: () => {// user has clicked the alert button// begin the alert's dismiss transitionconst navTransition = alert.dismiss();// start some async methodsomeAsyncOperation().then(() => {// once the async operation has completed// then run the next nav transition after the// first transition has finished animating outnavTransition.then(() => {this.nav.pop();});});return false;}}]});alert.present();It's important to note that the handler returns
false
. A feature of button handlers is that they automatically dismiss the alert when their button was clicked, however, we'll need more control regarding the transition. Because the handler returnsfalse
, then the alert does not automatically dismiss itself. Instead, you now have complete control of when the alert has finished transitioning, and the ability to wait for the alert to finish transitioning out before starting a new transition./docs/demos/src/alert/
constructor
constructor(_app: App, config: Config);
property config
config: Config;
method create
create: (opts?: AlertOptions) => Alert;
Display an alert with a title, inputs, and buttons
Parameter opts
Alert. See the table below
class Animation
class Animation {}
constructor
constructor(plt: Platform, ele?: any, opts?: AnimationOptions);
property hasChildren
hasChildren: boolean;
property hasCompleted
hasCompleted: boolean;
property isPlaying
isPlaying: boolean;
property opts
opts: AnimationOptions;
property parent
parent: Animation;
property plt
plt: Platform;
method add
add: (childAnimation: Animation) => Animation;
Add a child animation to this animation.
method afterAddClass
afterAddClass: (className: string) => Animation;
Add CSS class to this animation's elements after the animation finishes.
method afterClearStyles
afterClearStyles: (propertyNames: string[]) => Animation;
Clear CSS inline styles from this animation's elements after the animation finishes.
method afterRemoveClass
afterRemoveClass: (className: string) => Animation;
Remove CSS class from this animation's elements after the animation finishes.
method afterStyles
afterStyles: (styles: { [property: string]: any }) => Animation;
Set CSS inline styles to this animation's elements after the animation finishes.
method beforeAddClass
beforeAddClass: (className: string) => Animation;
Add CSS class to this animation's elements before the animation begins.
method beforeAddRead
beforeAddRead: (domReadFn: Function) => Animation;
Add a function which contains DOM reads, which will run before the animation begins.
method beforeAddWrite
beforeAddWrite: (domWriteFn: Function) => Animation;
Add a function which contains DOM writes, which will run before the animation begins.
method beforeClearStyles
beforeClearStyles: (propertyNames: string[]) => Animation;
Clear CSS inline styles from this animation's elements before the animation begins.
method beforeRemoveClass
beforeRemoveClass: (className: string) => Animation;
Remove CSS class from this animation's elements before the animation begins.
method beforeStyles
beforeStyles: (styles: { [property: string]: any }) => Animation;
Set CSS inline styles to this animation's elements before the animation begins.
method destroy
destroy: () => void;
Recursively destroy this animation and all child animations.
method duration
duration: (milliseconds: number) => Animation;
Set the duration for this animation.
method easing
easing: (name: string) => Animation;
Set the easing for this animation.
method easingReverse
easingReverse: (name: string) => Animation;
Set the easing for this reversed animation.
method element
element: (ele: any) => Animation;
method from
from: (prop: string, val: any) => Animation;
Add the "from" value for a specific property.
method fromTo
fromTo: ( prop: string, fromVal: any, toVal: any, clearProperyAfterTransition?: boolean) => Animation;
Shortcut to add both the "from" and "to" for the same property.
method getDuration
getDuration: (opts?: PlayOptions) => number;
Get the duration of this animation. If this animation does not have a duration, then it'll get the duration from its parent.
method getEasing
getEasing: () => string;
Get the easing of this animation. If this animation does not have an easing, then it'll get the easing from its parent.
method isRoot
isRoot: () => boolean;
Returns if the animation is a root one.
method onFinish
onFinish: ( callback: Function, onceTimeCallback?: boolean, clearOnFinishCallacks?: boolean) => Animation;
Add a callback to fire when the animation has finished.
method play
play: (opts?: PlayOptions) => void;
Play the animation.
method progressEnd
progressEnd: ( shouldComplete: boolean, currentStepValue: number, dur?: number) => void;
End the progress animation.
method progressStart
progressStart: () => void;
Start the animation with a user controlled progress.
method progressStep
progressStep: (stepValue: number) => void;
Set the progress step for this animation. progressStep() is not debounced, so it should not be called faster than 60FPS.
method reverse
reverse: (shouldReverse?: boolean) => Animation;
Reverse the animation.
method stop
stop: (stepValue?: number) => void;
Immediately stop at the end of the animation.
method syncPlay
syncPlay: () => void;
method to
to: (prop: string, val: any, clearProperyAfterTransition?: boolean) => Animation;
Add the "to" value for a specific property.
class App
class App {}
App App is a utility class used in Ionic to get information about various aspects of an app
constructor
constructor(_config: Config, _plt: Platform, _menuCtrl?: MenuController);
property viewDidEnter
viewDidEnter: EventEmitter<ViewController>;
Observable that emits after any view is entered in the app.
Returns
{Observable} Returns an observable
property viewDidLeave
viewDidLeave: EventEmitter<ViewController>;
Observable that emits after any view is exited in the app.
Returns
{Observable} Returns an observable
property viewDidLoad
viewDidLoad: EventEmitter<ViewController>;
Observable that emits whenever a view loads in the app.
Returns
{Observable} Returns an observable
property viewWillEnter
viewWillEnter: EventEmitter<ViewController>;
Observable that emits before any view is entered in the app.
Returns
{Observable} Returns an observable
property viewWillLeave
viewWillLeave: EventEmitter<ViewController>;
Observable that emits before any view is exited in the app.
Returns
{Observable} Returns an observable
property viewWillUnload
viewWillUnload: EventEmitter<ViewController>;
Observable that emits before any view unloads in the app.
Returns
{Observable} Returns an observable
method getActiveNav
getActiveNav: () => NavControllerBase;
{NavController} Returns the first Active Nav Controller from the list. This method is deprecated
method getActiveNavContainers
getActiveNavContainers: () => NavigationContainer[];
method getActiveNavs
getActiveNavs: (rootNavId?: string) => NavControllerBase[];
{NavController[]} Returns the active NavControllers. Using this method is preferred when we need access to the top-level navigation controller while on the outside views and handlers like
registerBackButtonAction()
method getNavByIdOrName
getNavByIdOrName: (id: string) => NavigationContainer;
method getRootNav
getRootNav: () => any;
method getRootNavById
getRootNavById: (navId: string) => NavigationContainer;
{NavController} Returns the root NavController
method getRootNavs
getRootNavs: () => any[];
method goBack
goBack: () => Promise<any>;
method isEnabled
isEnabled: () => boolean;
Boolean if the app is actively enabled or not. {boolean}
method isScrolling
isScrolling: () => boolean;
Boolean if the app is actively scrolling or not. {boolean} returns true or false
method navPop
navPop: () => Promise<any>;
method present
present: ( enteringView: ViewController, opts: NavOptions, appPortal?: number) => Promise<any>;
method registerRootNav
registerRootNav: (nav: NavigationContainer) => void;
method setElementClass
setElementClass: (className: string, isAdd: boolean) => void;
method setEnabled
setEnabled: ( isEnabled: boolean, duration?: number, minDuration?: number) => void;
Sets if the app is currently enabled or not, meaning if it's available to accept new user commands. For example, this is set to
false
while views transition, a modal slides up, an action-sheet slides up, etc. After the transition completes it is set back totrue
.Parameter isEnabled
true
for enabled,false
for disabledParameter duration
When
isEnabled
is set tofalse
, this argument is used to set the maximum number of milliseconds that app will wait until it will automatically enable the app again. It's basically a fallback incase something goes wrong during a transition and the app wasn't re-enabled correctly.
method setScrolling
setScrolling: () => void;
method setTitle
setTitle: (val: string) => void;
Sets the document title.
Parameter val
Value to set the document title to.
method unregisterRootNav
unregisterRootNav: (nav: NavigationContainer) => void;
class Avatar
class Avatar {}
Avatar ionic An Avatar is a component that creates a circular image for an item. Avatars can be placed on the left or right side of an item with the
item-start
oritem-end
directive.See Also
constructor
constructor();
class Backdrop
class Backdrop {}
constructor
constructor(_elementRef: ElementRef, _renderer: Renderer);
method getNativeElement
getNativeElement: () => HTMLElement;
method setElementClass
setElementClass: (className: string, add: boolean) => void;
class Badge
class Badge extends Ion {}
Badge ionic Badges are simple components in Ionic containing numbers or text. You can display a badge to indicate that there is new information associated with the item it is on.
See Also
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class BlockerDelegate
class BlockerDelegate {}
constructor
constructor( id: number, controller: GestureController, disable: string[], disableScroll: boolean);
property blocked
blocked: boolean;
method block
block: () => void;
method destroy
destroy: () => void;
method unblock
unblock: () => void;
class Button
class Button extends Ion {}
Button ionic Buttons are simple components in Ionic. They can consist of text and icons and be enhanced by a wide range of attributes.
<!-- Colors --><button ion-button>Default</button><button ion-button color="secondary">Secondary</button><button ion-button color="danger">Danger</button><button ion-button color="light">Light</button><button ion-button color="dark">Dark</button><!-- Shapes --><button ion-button full>Full Button</button><button ion-button block>Block Button</button><button ion-button round>Round Button</button><!-- Outline --><button ion-button full outline>Outline + Full</button><button ion-button block outline>Outline + Block</button><button ion-button round outline>Outline + Round</button><!-- Icons --><button ion-button icon-start><ion-icon name="star"></ion-icon>Left Icon</button><button ion-button icon-end>Right Icon<ion-icon name="star"></ion-icon></button><button ion-button icon-only><ion-icon name="star"></ion-icon></button><!-- Sizes --><button ion-button large>Large</button><button ion-button>Default</button><button ion-button small>Small</button><!-- Bind the color and outline inputs to an expression --><button ion-button [color]="isDanger ? 'danger' : 'primary'" [outline]="isOutline">Danger (Solid)</button><!-- Bind the color and round inputs to an expression --><button ion-button [color]="myColor" [round]="isRound">Secondary (Round)</button><!-- Bind the color and clear inputs to an expression --><button ion-button [color]="isSecondary ? 'secondary' : 'primary'" [clear]="isClear">Primary (Clear)</button><!-- Bind the color, outline and round inputs to an expression --><button ion-button [color]="myColor2" [outline]="isOutline" [round]="isRound">Dark (Solid + Round)</button><!-- Bind the click event to a method --><button ion-button (click)="logEvent($event)">Click me!</button>@Component({templateUrl: 'main.html'})class E2EPage {isDanger: boolean = true;isSecondary: boolean = false;isRound: boolean = true;isOutline: boolean = false;isClear: boolean = true;myColor: string = 'secondary';myColor2: string = 'dark';logEvent(event) {console.log(event)}}/docs/demos/src/button/
See Also
constructor
constructor( ionButton: string, config: Config, elementRef: ElementRef, renderer: Renderer);
property block
block: boolean;
{boolean} If true, activates a button style that fills the available width.
property clear
clear: boolean;
{boolean} If true, activates a transparent button style without a border.
property color
color: string;
{string} The color to use from your Sass
$colors
map. Default options are:"primary"
,"secondary"
,"danger"
,"light"
, and"dark"
. For more information, see [Theming your App](/docs/theming/theming-your-app).
property default
default: boolean;
{boolean} If true, activates the default button size. Normally the default, useful for buttons in an item.
property full
full: boolean;
{boolean} If true, activates a button style that fills the available width without a left and right border.
property large
large: boolean;
{boolean} If true, activates the large button size.
property mode
mode: string;
{string} The mode determines which platform styles to use. Possible values are:
"ios"
,"md"
, or"wp"
. For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
property outline
outline: boolean;
{boolean} If true, activates a transparent button style with a border.
property round
round: boolean;
{boolean} If true, activates a button with rounded corners.
property small
small: boolean;
{boolean} If true, activates the small button size.
property solid
solid: boolean;
{boolean} If true, activates a solid button style. Normally the default, useful for buttons in a toolbar.
property strong
strong: boolean;
{boolean} If true, activates a button with a heavier font weight.
method ngAfterContentInit
ngAfterContentInit: () => void;
method setRole
setRole: (val: string) => void;
class Card
class Card extends Ion {}
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class CardContent
class CardContent extends Ion {}
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class CardHeader
class CardHeader extends Ion {}
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class CardTitle
class CardTitle extends Ion {}
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class Checkbox
class Checkbox extends BaseInput<boolean> implements IonicTapInput, OnDestroy {}
Checkbox ionic
The Checkbox is a simple component styled based on the mode. It can be placed in an
ion-item
or used as a stand-alone checkbox.See the [Angular Docs](https://angular.io/docs/ts/latest/guide/forms.html) for more info on forms and inputs.
<ion-list><ion-item><ion-label>Pepperoni</ion-label><ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox></ion-item><ion-item><ion-label>Sausage</ion-label><ion-checkbox [(ngModel)]="sausage" disabled="true"></ion-checkbox></ion-item><ion-item><ion-label>Mushrooms</ion-label><ion-checkbox [(ngModel)]="mushrooms"></ion-checkbox></ion-item></ion-list><!-- Call function when state changes --><ion-list><ion-item><ion-label>Cucumber</ion-label><ion-checkbox [(ngModel)]="cucumber" (ionChange)="updateCucumber()"></ion-checkbox></ion-item></ion-list>@Component({templateUrl: 'main.html'})class SaladPage {cucumber: boolean;updateCucumber() {console.log('Cucumbers new state:' + this.cucumber);}}/docs/demos/src/checkbox/
See Also
constructor
constructor( config: Config, form: Form, item: Item, elementRef: ElementRef, renderer: Renderer);
property checked
checked: boolean;
{boolean} If true, the element is selected.
class Chip
class Chip extends Ion {}
Chip ionic Chips represent complex entities in small blocks, such as a contact.
<ion-chip><ion-label>Default</ion-label></ion-chip><ion-chip><ion-label color="secondary">Secondary Label</ion-label></ion-chip><ion-chip color="secondary"><ion-label color="dark">Secondary w/ Dark label</ion-label></ion-chip><ion-chip color="danger"><ion-label>Danger</ion-label></ion-chip><ion-chip><ion-icon name="pin"></ion-icon><ion-label>Default</ion-label></ion-chip><ion-chip><ion-icon name="heart" color="dark"></ion-icon><ion-label>Default</ion-label></ion-chip><ion-chip><ion-avatar><img src="assets/img/my-img.png"></ion-avatar><ion-label>Default</ion-label></ion-chip><ion-chip #chip1><ion-label>Default</ion-label><button ion-button clear color="light" (click)="delete(chip1)"><ion-icon name="close-circle"></ion-icon></button></ion-chip><ion-chip #chip2><ion-icon name="pin" color="primary"></ion-icon><ion-label>With Icon</ion-label><button ion-button (click)="delete(chip2)"><ion-icon name="close"></ion-icon></button></ion-chip><ion-chip #chip3><ion-avatar><img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw=="></ion-avatar><ion-label>With Avatar</ion-label><button ion-button clear color="dark" (click)="delete(chip3)"><ion-icon name="close-circle"></ion-icon></button></ion-chip>@Component({templateUrl: 'main.html'})class E2EPage {delete(chip: Element) {chip.remove();}}/docs/demos/src/chip/
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class Col
class Col {}
Col ionic
Columns are cellular components of the [grid](../Grid) system and go inside of a [row](../Row). They will expand to fill their row. All content within a grid should go inside of a column.
## Column attributes
By default, columns will stretch to fill the entire height of the row. There are several attributes that can be added to a column to customize this behavior.
| Property | Description | |-----------------------|-------------------------------------------------------------------------------------------------------------| | align-self-start | Adds
align-self: flex-start
. The column will be vertically aligned at the top. | | align-self-center | Addsalign-self: center
. The column will be vertically aligned in the center. | | align-self-end | Addsalign-self: flex-end
. The column will be vertically aligned at the bottom. | | align-self-stretch | Addsalign-self: stretch
. The column will be stretched to take up the entire height of the row. | | align-self-baseline | Addsalign-self: baseline
. The column will be vertically aligned at its baseline. |
class Config
class Config {}
Config /docs/demos/src/config/ The Config lets you configure your entire app or specific platforms. You can set the tab placement, icon mode, animations, and more here.
import { IonicApp, IonicModule } from 'ionic-angular';@NgModule({declarations: [ MyApp ],imports: [BrowserModule,IonicModule.forRoot(MyApp, {backButtonText: 'Go Back',iconMode: 'ios',modalEnter: 'modal-slide-in',modalLeave: 'modal-slide-out',tabsPlacement: 'bottom',pageTransition: 'ios-transition'}, {})],bootstrap: [IonicApp],entryComponents: [ MyApp ],providers: []})Config can be overwritten at multiple levels allowing for more granular configuration. Below is an example where an app can override any setting we want based on a platform.
import { IonicModule } from 'ionic-angular';@NgModule({...imports: [BrowserModule,IonicModule.forRoot(MyApp, {tabsPlacement: 'bottom',platforms: {ios: {tabsPlacement: 'top',}}}, {})],...})We could also configure these values at a component level. Take
tabsPlacement
, we can configure this as a property on ourion-tabs
.<ion-tabs tabsPlacement="top"><ion-tab tabTitle="Dash" tabIcon="pulse" [root]="tabRoot"></ion-tab></ion-tabs>The last way we could configure is through URL query strings. This is useful for testing while in the browser. Simply add
?ionic<PROPERTYNAME>=<value>
to the url.http://localhost:8100/?ionicTabsPlacement=bottomAny value can be added to config, and looked up at a later in any component.
config.set('ios', 'favoriteColor', 'green');// from any page in your app:config.get('favoriteColor'); // 'green' when iOSA config value can come from anywhere and be anything, but there are default values for each mode. The [theming](../../../theming/platform-specific-styles/) documentation has a chart of the default mode configuration. The following chart displays each property with a description of what it controls.
| Config Property | Type | Details | |--------------------------|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------| |
activator
|string
| Used for buttons, changes the effect of pressing on a button. Available options:"ripple"
,"highlight"
. | |actionSheetEnter
|string
| The name of the transition to use while an action sheet is presented. | |actionSheetLeave
|string
| The name of the transition to use while an action sheet is dismissed. | |alertEnter
|string
| The name of the transition to use while an alert is presented. | |alertLeave
|string
| The name of the transition to use while an alert is dismissed. | |backButtonText
|string
| The text to display by the back button icon in the navbar. | |backButtonIcon
|string
| The icon to use as the back button icon. | |iconMode
|string
| The mode to use for all icons throughout the application. Available options:"ios"
,"md"
| |locationStrategy
|string
| Set to 'path' to remove hashbangs when using Deeplinking. | |loadingEnter
|string
| The name of the transition to use while a loading indicator is presented. | |loadingLeave
|string
| The name of the transition to use while a loading indicator is dismissed. | |menuType
|string
| Type of menu to display. Available options:"overlay"
,"reveal"
,"push"
. | |modalEnter
|string
| The name of the transition to use while a modal is presented. | |modalLeave
|string
| The name of the transition to use while a modal is dismiss. | |mode
|string
| The mode to use throughout the application. | |pageTransition
|string
| The name of the transition to use while changing pages. Available options:"ios-transition"
,"md-transition"
,"wp-transition"
. | |pickerEnter
|string
| The name of the transition to use while a picker is presented. | |pickerLeave
|string
| The name of the transition to use while a picker is dismissed. | |popoverEnter
|string
| The name of the transition to use while a popover is presented. | |popoverLeave
|string
| The name of the transition to use while a popover is dismissed. |scrollAssist
|boolean
| Used to avoid the input to be hidden by the keyboard if it's near the bottom of the page. |scrollPadding
|boolean
| Used to remove the extra padding on ion-content when keyboard is displayed. |spinner
|string
| The default spinner to use when a name is not defined. | |statusbarPadding
|boolean
| Whether to hide extra padding for statusbar. | |swipeBackEnabled
|boolean
| Whether native iOS swipe to go back functionality is enabled. | |tabsHighlight
|boolean
| Whether to show a highlight line under the tab when it is selected. | |tabsLayout
|string
| The layout to use for all tabs. Available options:"icon-top"
,"icon-start"
,"icon-end"
,"icon-bottom"
,"icon-hide"
,"title-hide"
. | |tabsPlacement
|string
| The position of the tabs relative to the content. Available options:"top"
,"bottom"
| |tabsHideOnSubPages
|boolean
| Whether to hide the tabs on child pages or not. Iftrue
it will not show the tabs on child pages. | |toastEnter
|string
| The name of the transition to use while a toast is presented. | |toastLeave
|string
| The name of the transition to use while a toast is dismissed. |
property plt
plt: Platform;
method get
get: (key: string, fallbackValue?: any) => any;
get Returns a single config value, given a key.
Parameter key
the key for the config value
Parameter fallbackValue
a fallback value to use when the config value was not found, or is config value is
null
. Fallback value defaults tonull
.
method getBoolean
getBoolean: (key: string, fallbackValue?: boolean) => boolean;
getBoolean Same as
get()
, however always returns a boolean value. If the value fromget()
isnull
, then it'll return thefallbackValue
which defaults tofalse
. Otherwise,getBoolean()
will return if the config value is truthy or not. It also returnstrue
if the config value was the string value"true"
.Parameter key
the key for the config value
Parameter fallbackValue
a fallback value to use when the config value was
null
. Fallback value defaults tofalse
.
method getModeConfig
getModeConfig: (modeName: string) => any;
method getNumber
getNumber: (key: string, fallbackValue?: number) => number;
getNumber Same as
get()
, however always returns a number value. UsesparseFloat()
on the value received fromget()
. If the result from the parse isNaN
, then it will return the value passed tofallbackValue
. If no fallback value was provided then it'll default to returningNaN
when the result is not a valid number.Parameter key
the key for the config value
Parameter fallbackValue
a fallback value to use when the config value turned out to be
NaN
. Fallback value defaults toNaN
.
method getTransition
getTransition: (trnsName: string) => any;
method init
init: (config: any, plt: Platform) => void;
method parseNumber
parseNumber: (value: string, fallbackValue?: number) => number;
method set
set: (...args: any[]) => this;
set Sets a single config value.
Parameter platform
The platform (either 'ios' or 'android') that the config value should apply to. Leaving this blank will apply the config value to all platforms.
Parameter key
The key used to look up the value at a later point in time.
Parameter value
The config value being stored.
method setModeConfig
setModeConfig: (modeName: string, modeConfig: any) => void;
method settings
settings: (arg0?: any, arg1?: any) => any;
settings()
method setTransition
setTransition: (trnsName: string, trnsClass: any) => void;
class Content
class Content extends Ion implements OnDestroy, AfterViewInit, IContent {}
Content The Content component provides an easy to use content area with some useful methods to control the scrollable area. There should only be one content in a single view component. If additional scrollable elements are needed, use [ionScroll](../../scroll/Scroll).
The content area can also implement pull-to-refresh with the [Refresher](../../refresher/Refresher) component.
<ion-content>Add your content here!</ion-content>To get a reference to the content component from a Page's logic, you can use Angular's
@ViewChild
annotation:import { Component, ViewChild } from '@angular/core';import { Content } from 'ionic-angular';@Component({...})export class MyPage{@ViewChild(Content) content: Content;scrollToTop() {this.content.scrollToTop();}}### Scroll Events
Scroll events happen outside of Angular's Zones. This is for performance reasons. So if you're trying to bind a value to any scroll event, it will need to be wrapped in a
zone.run()
import { Component, NgZone } from '@angular/core';@Component({template: `<ion-header><ion-navbar><ion-title>{{scrollAmount}}</ion-title></ion-navbar></ion-header><ion-content (ionScroll)="scrollHandler($event)"><p> Some realllllllly long content </p></ion-content>`})class E2EPage {public scrollAmount = 0;constructor( public zone: NgZone){}scrollHandler(event) {console.log(`ScrollEvent: ${event}`)this.zone.run(()=>{// since scrollAmount is data-binded,// the update needs to happen in zonethis.scrollAmount++})}}This goes for any scroll event, not just
ionScroll
.### Resizing the content
If the height of
ion-header
,ion-footer
orion-tabbar
changes dynamically,content.resize()
has to be called in order to update the layout ofContent
.@Component({template: `<ion-header><ion-navbar><ion-title>Main Navbar</ion-title></ion-navbar><ion-toolbar *ngIf="showToolbar"><ion-title>Dynamic Toolbar</ion-title></ion-toolbar></ion-header><ion-content><button ion-button (click)="toggleToolbar()">Toggle Toolbar</button></ion-content>`})class E2EPage {@ViewChild(Content) content: Content;showToolbar: boolean = false;toggleToolbar() {this.showToolbar = !this.showToolbar;this.content.resize();}}Scroll to a specific position
import { Component, ViewChild } from '@angular/core';import { Content } from 'ionic-angular';@Component({template: `<ion-content><button ion-button (click)="scrollTo()">Down 500px</button></ion-content>`)}export class MyPage{@ViewChild(Content) content: Content;scrollTo() {// set the scrollLeft to 0px, and scrollTop to 500px// the scroll duration should take 200msthis.content.scrollTo(0, 500, 200);}}
constructor
constructor( config: Config, _plt: Platform, _dom: DomController, elementRef: ElementRef, renderer: Renderer, _app: App, _keyboard: Keyboard, _zone: NgZone, viewCtrl: ViewController, navCtrl: NavController);
property contentBottom
contentBottom: number;
A number representing how many pixels the bottom of the content has been adjusted, which could be by either padding or margin. This adjustment is to account for the space needed for the footer.
{number}
property contentHeight
readonly contentHeight: number;
Content height of the viewable area. This does not include content which is outside the overflow area, or content area which is under headers and footers. Read-only.
{number}
property contentTop
contentTop: number;
A number representing how many pixels the top of the content has been adjusted, which could be by either padding or margin. This adjustment is to account for the space needed for the header.
{number}
property contentWidth
readonly contentWidth: number;
Content width including content which is not visible on the screen due to overflow. Read-only.
{number}
property directionX
readonly directionX: string;
The current, or last known, horizontal scroll direction. Possible string values include
right
andleft
.{string}
property directionY
readonly directionY: string;
The current, or last known, vertical scroll direction. Possible string values include
down
andup
.{string}
property fullscreen
fullscreen: boolean;
{boolean} If true, the content will scroll behind the headers and footers. This effect can easily be seen by setting the toolbar to transparent.
property ionScroll
ionScroll: EventEmitterProxy<ScrollEvent>;
{ScrollEvent} Emitted on every scroll event.
property ionScrollEnd
ionScrollEnd: EventEmitterProxy<ScrollEvent>;
{ScrollEvent} Emitted when scrolling ends.
property ionScrollStart
ionScrollStart: EventEmitterProxy<ScrollEvent>;
{ScrollEvent} Emitted when the scrolling first starts.
property isScrolling
readonly isScrolling: boolean;
If the content is actively scrolling or not.
{boolean}
property scrollDownOnLoad
scrollDownOnLoad: boolean;
{boolean} If true, the content will scroll down on load.
property scrollHeight
readonly scrollHeight: number;
Content height including content which is not visible on the screen due to overflow. Read-only.
{number}
property scrollLeft
scrollLeft: number;
Parameter top
property scrollTop
scrollTop: number;
Parameter top
property scrollWidth
readonly scrollWidth: number;
Content width including content which is not visible due to overflow. Read-only.
{number}
property statusbarPadding
statusbarPadding: boolean;
method addImg
addImg: (img: Img) => void;
method addScrollPadding
addScrollPadding: (newPadding: number) => void;
DOM WRITE Adds padding to the bottom of the scroll element when the keyboard is open so content below the keyboard can be scrolled into view.
method clearScrollPaddingFocusOut
clearScrollPaddingFocusOut: () => void;
DOM WRITE
method enableJsScroll
enableJsScroll: () => void;
method getContentDimensions
getContentDimensions: () => ContentDimensions;
Returns the content and scroll elements' dimensions.
Returns
{object} dimensions The content and scroll elements' dimensions {number} dimensions.contentHeight content offsetHeight {number} dimensions.contentTop content offsetTop {number} dimensions.contentBottom content offsetTop+offsetHeight {number} dimensions.contentWidth content offsetWidth {number} dimensions.contentLeft content offsetLeft {number} dimensions.contentRight content offsetLeft + offsetWidth {number} dimensions.scrollHeight scroll scrollHeight {number} dimensions.scrollTop scroll scrollTop {number} dimensions.scrollBottom scroll scrollTop + scrollHeight {number} dimensions.scrollWidth scroll scrollWidth {number} dimensions.scrollLeft scroll scrollLeft {number} dimensions.scrollRight scroll scrollLeft + scrollWidth
method getFixedElement
getFixedElement: () => HTMLElement;
method getScrollElement
getScrollElement: () => HTMLElement;
method imgsUpdate
imgsUpdate: () => void;
method isImgsUpdatable
isImgsUpdatable: () => boolean;
method ngAfterViewInit
ngAfterViewInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method onScrollElementTransitionEnd
onScrollElementTransitionEnd: (callback: (ev: TransitionEvent) => void) => void;
method removeImg
removeImg: (img: Img) => void;
method resize
resize: () => void;
Tell the content to recalculate its dimensions. This should be called after dynamically adding/removing headers, footers, or tabs.
method scrollTo
scrollTo: ( x: number, y: number, duration?: number, done?: Function) => Promise<any>;
Scroll to the specified position.
Parameter x
The x-value to scroll to.
Parameter y
The y-value to scroll to.
Parameter duration
Duration of the scroll animation in milliseconds. Defaults to
300
.Returns
{Promise} Returns a promise which is resolved when the scroll has completed.
method scrollToBottom
scrollToBottom: (duration?: number) => Promise<any>;
Scroll to the bottom of the content component.
Parameter duration
Duration of the scroll animation in milliseconds. Defaults to
300
.Returns
{Promise} Returns a promise which is resolved when the scroll has completed.
method scrollToTop
scrollToTop: (duration?: number) => Promise<any>;
Scroll to the top of the content component.
Parameter duration
Duration of the scroll animation in milliseconds. Defaults to
300
.Returns
{Promise} Returns a promise which is resolved when the scroll has completed.
method setScrollElementStyle
setScrollElementStyle: (prop: string, val: any) => void;
DOM WRITE
class DateTime
class DateTime extends BaseInput<DateTimeData> implements AfterContentInit, ControlValueAccessor, OnDestroy {}
DateTime The DateTime component is used to present an interface which makes it easy for users to select dates and times. Tapping on
<ion-datetime>
will display a picker interface that slides up from the bottom of the page. The picker then displays scrollable columns that can be used to individually select years, months, days, hours and minute values. The DateTime component is similar to the native<input type="datetime-local">
element, however, Ionic's DateTime component makes it easy to display the date and time in a preferred format, and manage the datetime values.<ion-item><ion-label>Date</ion-label><ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="myDate"></ion-datetime></ion-item>## Display and Picker Formats
The DateTime component displays the values in two places: in the
<ion-datetime>
component, and in the interface that is presented from the bottom of the screen. The following chart lists all of the formats that can be used.| Format | Description | Example | |---------|--------------------------------|-------------------------| |
YYYY
| Year, 4 digits |2018
| |YY
| Year, 2 digits |18
| |M
| Month |1
...12
| |MM
| Month, leading zero |01
...12
| |MMM
| Month, short name |Jan
| |MMMM
| Month, full name |January
| |D
| Day |1
...31
| |DD
| Day, leading zero |01
...31
| |DDD
| Day, short name |Fri
| |DDDD
| Day, full name |Friday
| |H
| Hour, 24-hour |0
...23
| |HH
| Hour, 24-hour, leading zero |00
...23
| |h
| Hour, 12-hour |1
...12
| |hh
| Hour, 12-hour, leading zero |01
...12
| |a
| 12-hour time period, lowercase |am
pm
| |A
| 12-hour time period, uppercase |AM
PM
| |m
| Minute |1
...59
| |mm
| Minute, leading zero |01
...59
| |s
| Second |1
...59
| |ss
| Second, leading zero |01
...59
| |Z
| UTC Timezone Offset |Z or +HH:mm or -HH:mm
|**Important**: See the [Month Names and Day of the Week Names](#month-names-and-day-of-the-week-names) section below on how to use different names for the month and day.
### Display Format
The
displayFormat
input property specifies how a datetime's value should be printed, as formatted text, within theion-datetime
component.In the following example, the display in the
<ion-datetime>
will use the month's short name, the numerical day with a leading zero, a comma and the four-digit year. In addition to the date, it will display the time with the hours in the 24-hour format and the minutes. Any character can be used as a separator. An example display using this format is:Jun 17, 2005 11:06
.<ion-item><ion-label>Date</ion-label><ion-datetime displayFormat="MMM DD, YYYY HH:mm" [(ngModel)]="myDate"></ion-datetime></ion-item>### Picker Format
The
pickerFormat
input property determines which columns should be shown in the interface, the order of the columns, and which format to use within each column. If thepickerFormat
input is not provided then it will default to thedisplayFormat
.In the following example, the display in the
<ion-datetime>
will use theMM/YYYY
format, such as06/2020
. However, the picker interface will display two columns with the month's long name, and the four-digit year.<ion-item><ion-label>Date</ion-label><ion-datetime displayFormat="MM/YYYY" pickerFormat="MMMM YYYY" [(ngModel)]="myDate"></ion-datetime></ion-item>### Datetime Data
Historically, handling datetime values within JavaScript, or even within HTML inputs, has always been a challenge. Specifically, JavaScript's
Date
object is notoriously difficult to correctly parse apart datetime strings or to format datetime values. Even worse is how different browsers and JavaScript versions parse various datetime strings differently, especially per locale.But no worries, all is not lost! Ionic's datetime input has been designed so developers can avoid the common pitfalls, allowing developers to easily format datetime values within the input, and give the user a simple datetime picker for a great user experience.
##### ISO 8601 Datetime Format: YYYY-MM-DDTHH:mmZ
Ionic uses the [ISO 8601 datetime format](https://www.w3.org/TR/NOTE-datetime) for its value. The value is simply a string, rather than using JavaScript's
Date
object. Additionally, when using the ISO datetime format, it makes it easier to serialize and pass within JSON objects, and sending databases a standardized format which it can be easily parsed if need be.To create an ISO datetime string for the current date and time, e.g. use
const currentDate = (new Date()).toISOString();
.An ISO format can be used as a simple year, or just the hour and minute, or get more detailed down to the millisecond and timezone. Any of the ISO formats below can be used, and after a user selects a new value, Ionic will continue to use the same ISO format which datetime value was originally given as.
| Description | Format | Datetime Value Example | |----------------------|------------------------|------------------------------| | Year | YYYY | 1994 | | Year and Month | YYYY-MM | 1994-12 | | Complete Date | YYYY-MM-DD | 1994-12-15 | | Date and Time | YYYY-MM-DDTHH:mm | 1994-12-15T13:47 | | UTC Timezone | YYYY-MM-DDTHH:mm:ssTZD | 1994-12-15T13:47:20.789Z | | Timezone Offset | YYYY-MM-DDTHH:mm:ssTZD | 1994-12-15T13:47:20.789+5:00 | | Hour and Minute | HH:mm | 13:47 | | Hour, Minute, Second | HH:mm:ss | 13:47:20 |
Note that the year is always four-digits, milliseconds (if it's added) is always three-digits, and all others are always two-digits. So the number representing January always has a leading zero, such as
01
. Additionally, the hour is always in the 24-hour format, so00
is12am
on a 12-hour clock,13
means1pm
, and23
means11pm
.It's also important to note that neither the
displayFormat
orpickerFormat
can set the datetime value's output, which is the value that is set by the component'sngModel
. The format's are merely for displaying the value as text and the picker's interface, but the datetime's value is always persisted as a valid ISO 8601 datetime string.## Min and Max Datetimes
Dates are infinite in either direction, so for a user's selection there should be at least some form of restricting the dates that can be selected. By default, the maximum date is to the end of the current year, and the minimum date is from the beginning of the year that was 100 years ago.
To customize the minimum and maximum datetime values, the
min
andmax
component inputs can be provided which may make more sense for the app's use-case, rather than the default of the last 100 years. Following the same IS0 8601 format listed in the table above, each component can restrict which dates can be selected by the user. Below is an example of restricting the date selection between the beginning of 2016, and October 31st of 2020:<ion-item><ion-label>Date</ion-label><ion-datetime displayFormat="MMMM YYYY" min="2016" max="2020-10-31" [(ngModel)]="myDate"></ion-datetime></ion-item>## Month Names and Day of the Week Names
At this time, there is no one-size-fits-all standard to automatically choose the correct language/spelling for a month name, or day of the week name, depending on the language or locale. Good news is that there is an [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat) standard which *most* browsers have adopted. However, at this time the standard has not been fully implemented by all popular browsers so Ionic is unavailable to take advantage of it *yet*. Additionally, Angular also provides an internationalization service, but it is still under heavy development so Ionic does not depend on it at this time.
All things considered, the by far easiest solution is to just provide an array of names if the app needs to use names other than the default English version of month and day names. The month names and day names can be either configured at the app level, or individual
ion-datetime
level.### App Config Level
//app.module.ts@NgModule({...,imports: [IonicModule.forRoot(MyApp, {monthNames: ['janeiro', 'fevereiro', 'mar\u00e7o', ... ],monthShortNames: ['jan', 'fev', 'mar', ... ],dayNames: ['domingo', 'segunda-feira', 'ter\u00e7a-feira', ... ],dayShortNames: ['dom', 'seg', 'ter', ... ],})],...})### Component Input Level
<ion-item><ion-label>PerÃodo</ion-label><ion-datetime displayFormat="DDDD MMM D, YYYY" [(ngModel)]="myDate"monthNames="janeiro, fevereiro, mar\u00e7o, ..."monthShortNames="jan, fev, mar, ..."dayNames="domingo, segunda-feira, ter\u00e7a-feira, ..."dayShortNames="dom, seg, ter, ..."></ion-datetime></ion-item>### Advanced Datetime Validation and Manipulation
The datetime picker provides the simplicity of selecting an exact format, and persists the datetime values as a string using the standardized [ISO 8601 datetime format](https://www.w3.org/TR/NOTE-datetime). However, it's important to note that
ion-datetime
does not attempt to solve all situtations when validating and manipulating datetime values. If datetime values need to be parsed from a certain format, or manipulated (such as adding 5 days to a date, subtracting 30 minutes, etc.), or even formatting data to a specific locale, then we highly recommend using [moment.js](http://momentjs.com/) to "Parse, validate, manipulate, and display dates in JavaScript". [Moment.js](http://momentjs.com/) has quickly become our goto standard when dealing with datetimes within JavaScript, but Ionic does not prepackage this dependency since most apps will not require it, and its locale configuration should be decided by the end-developer.<ion-item><ion-label>Date</ion-label><ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="myDate"></ion-datetime></ion-item>/docs/demos/src/datetime/
constructor
constructor( form: Form, config: Config, elementRef: ElementRef, renderer: Renderer, item: Item, _pickerCtrl: PickerController);
property cancelText
cancelText: string;
{string} The text to display on the picker's cancel button. Default:
Cancel
.
property dayNames
dayNames: any;
{array} Full day of the week names. This can be used to provide locale names for each day in the week. Defaults to English.
property dayShortNames
dayShortNames: any;
{array} Short abbreviated day of the week names. This can be used to provide locale names for each day in the week. Defaults to English.
property dayValues
dayValues: any;
{array | string} Values used to create the list of selectable days. By default every day is shown for the given month. However, to control exactly which days of the month to display, the
dayValues
input can take either an array of numbers, or string of comma separated numbers. Note that even if the array days have an invalid number for the selected month, like31
in February, it will correctly not show days which are not valid for the selected month.
property displayFormat
displayFormat: string;
{string} The display format of the date and time as text that shows within the item. When the
pickerFormat
input is not used, then thedisplayFormat
is used for both display the formatted text, and determining the datetime picker's columns. See thepickerFormat
input description for more info. Defaults toMMM D, YYYY
.
property doneText
doneText: string;
{string} The text to display on the picker's "Done" button. Default:
Done
.
property hourValues
hourValues: any;
{array | string} Values used to create the list of selectable hours. By default the hour values range from
0
to23
for 24-hour, or1
to12
for 12-hour. However, to control exactly which hours to display, thehourValues
input can take either an array of numbers, or string of comma separated numbers.
property initialValue
initialValue: string;
{string} The default datetime selected in picker modal if field value is empty. Value must be a date string following the [ISO 8601 datetime format standard](https://www.w3.org/TR/NOTE-datetime),
1996-12-19
.
property ionCancel
ionCancel: EventEmitter<any>;
{any} Emitted when the datetime selection was cancelled.
property max
max: string;
{string} The maximum datetime allowed. Value must be a date string following the [ISO 8601 datetime format standard](https://www.w3.org/TR/NOTE-datetime),
1996-12-19
. The format does not have to be specific to an exact datetime. For example, the maximum could just be the year, such as1994
. Defaults to the end of this year.
property min
min: string;
{string} The minimum datetime allowed. Value must be a date string following the [ISO 8601 datetime format standard](https://www.w3.org/TR/NOTE-datetime), such as
1996-12-19
. The format does not have to be specific to an exact datetime. For example, the minimum could just be the year, such as1994
. Defaults to the beginning of the year, 100 years ago from today.
property minuteValues
minuteValues: any;
{array | string} Values used to create the list of selectable minutes. By default the mintues range from
0
to59
. However, to control exactly which minutes to display, theminuteValues
input can take either an array of numbers, or string of comma separated numbers. For example, if the minute selections should only be every 15 minutes, then this input value would beminuteValues="0,15,30,45"
.
property monthNames
monthNames: any;
{array} Full names for each month name. This can be used to provide locale month names. Defaults to English.
property monthShortNames
monthShortNames: any;
{array} Short abbreviated names for each month name. This can be used to provide locale month names. Defaults to English.
property monthValues
monthValues: any;
{array | string} Values used to create the list of selectable months. By default the month values range from
1
to12
. However, to control exactly which months to display, themonthValues
input can take either an array of numbers, or string of comma separated numbers. For example, if only summer months should be shown, then this input value would bemonthValues="6,7,8"
. Note that month numbers do *not* have a zero-based index, meaning January's value is1
, and December's is12
.
property pickerFormat
pickerFormat: string;
{string} The format of the date and time picker columns the user selects. A datetime input can have one or many datetime parts, each getting their own column which allow individual selection of that particular datetime part. For example, year and month columns are two individually selectable columns which help choose an exact date from the datetime picker. Each column follows the string parse format. Defaults to use
displayFormat
.
property pickerOptions
pickerOptions: any;
{any} Any additional options that the picker interface can accept. See the [Picker API docs](../../picker/Picker) for the picker options.
property placeholder
placeholder: string;
{string} The text to display when there's no date selected yet. Using lowercase to match the input attribute
property yearValues
yearValues: any;
{array | string} Values used to create the list of selectable years. By default the year values range between the
min
andmax
datetime inputs. However, to control exactly which years to display, theyearValues
input can take either an array of numbers, or string of comma separated numbers. For example, to show upcoming and recent leap years, then this input's value would beyearValues="2024,2020,2016,2012,2008"
.
method calcMinMax
calcMinMax: (now?: Date) => void;
method divyColumns
divyColumns: () => void;
method generate
generate: () => void;
method getDefaultValueDateString
getDefaultValueDateString: () => string;
Get the default value as a date string
method getValue
getValue: () => DateTimeData;
method getValueOrDefault
getValueOrDefault: () => DateTimeData;
method hasValue
hasValue: () => boolean;
method ngAfterContentInit
ngAfterContentInit: () => void;
method open
open: () => void;
method updateText
updateText: () => void;
method validate
validate: () => void;
method validateColumn
validateColumn: ( name: string, index: number, min: number, max: number, lowerBounds: number[], upperBounds: number[]) => number;
class DeepLinker
class DeepLinker {}
constructor
constructor( _app: App, _serializer: UrlSerializer, _location: Location, _moduleLoader: ModuleLoader, _baseCfr: ComponentFactoryResolver);
method getComponentFromName
getComponentFromName: (componentName: string) => Promise<any>;
method getCurrentSegments
getCurrentSegments: (browserUrl?: string) => NavSegment[];
method getNavLinkComponent
getNavLinkComponent: (link: NavLink) => Promise<any>;
method getSegmentFromNav
getSegmentFromNav: ( nav: NavController, component?: any, data?: any) => NavSegment;
method getSegmentFromTab
getSegmentFromTab: ( navContainer: NavigationContainer, component?: any, data?: any) => NavSegment;
method getSegmentsFromNav
getSegmentsFromNav: (nav: NavigationContainer) => NavSegment[];
class DeepLinkMetadata
class DeepLinkMetadata implements IonicPageMetadata {}
property component
component?: any;
property defaultHistory
defaultHistory?: any[] | string[];
property loadChildren
loadChildren?: string;
property name
name?: string;
property priority
priority?: string;
property segment
segment?: string;
class DisplayWhen
class DisplayWhen {}
constructor
constructor(conditions: string, _plt: Platform, zone: NgZone);
property conditions
conditions: string[];
property isMatch
isMatch: boolean;
property resizeObs
resizeObs: any;
property zone
zone: NgZone;
method ngOnDestroy
ngOnDestroy: () => void;
method orientation
orientation: () => boolean;
class DomController
class DomController {}
class Events
class Events {}
Events Events is a publish-subscribe style event system for sending and responding to application-level events across your app.
import { Events } from 'ionic-angular';// first page (publish an event when a user is created)constructor(public events: Events) { }createUser(user) {console.log('User created!')this.events.publish('user:created', user, Date.now());}// second page (listen for the user created event after function is called)constructor(public events: Events) {events.subscribe('user:created', (user, time) => {// user and time are the same arguments passed in `events.publish(user, time)`console.log('Welcome', user, 'at', time);});}/docs/demos/src/events/
method publish
publish: (topic: string, ...args: any[]) => any[];
Publish an event to the given topic.
Parameter topic
the topic to publish to
Parameter eventData
the data to send as the event
method subscribe
subscribe: (topic: string, ...handlers: Function[]) => void;
Subscribe to an event topic. Events that get posted to that topic will trigger the provided handler.
Parameter topic
the topic to subscribe to
Parameter handler
the event handler
method unsubscribe
unsubscribe: (topic: string, handler?: Function) => boolean;
Unsubscribe from the given topic. Your handler will no longer receive events published to this topic.
Parameter topic
the topic to unsubscribe from
Parameter handler
the event handler
true if a handler was removed
class FabButton
class FabButton extends Ion {}
FabButton ionic
FABs (Floating Action Buttons) are standard material design components. They are shaped as a circle that represents a promoted action. When pressed, it may contain more related actions. FABs as its name suggests are floating over the content in a fixed position. This is not achieved exclusively with
<button ion-fab>Button</button>
but it has to be wrapped with the<ion-fab>
component, like this:<ion-content><!-- Real floating action button, fixed. It will not scroll with the content --><ion-fab><button ion-fab>Button</button></ion-fab><!-- Button shaped as a circle that just like a normal button scrolls with the content --><button ion-fab>Button</button></ion-content>In case the button is not wrapped with
<ion-fab>
, the fab button will behave like a normal button, scrolling with the content.See [ion-fab] to learn more information about how to position the fab button.
[mini] - Makes a fab button with a reduced size.
<!-- Colors --><ion-fab><button ion-fab color="primary">Button</button></ion-fab><!-- Mini --><ion-fab><button ion-fab mini>Small</button></ion-fab>/docs/demos/src/fab/
See Also
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
method setActiveClose
setActiveClose: (closeVisible: boolean) => void;
class FabContainer
class FabContainer {}
FabContainer ionic
<ion-fab>
is not a FAB button by itself but a container that assist the fab button (<button ion-fab>
) allowing it to be placed in fixed position that does not scroll with the content. It is also used to implement "material design speed dial", ie. a FAB buttons displays a small lists of related actions when clicked.[top] - Places the container on the top of the content [bottom] - Places the container on the bottom of the content [left] - Places the container on the left [right] - Places the container on the right [middle] - Places the container on the middle vertically [center] - Places the container on the center horizontally [edge] - Used to place the container between the content and the header/footer
<!-- this fab is placed at top right --><ion-content><ion-fab top right><button ion-fab>Button</button></ion-fab><!-- this fab is placed at the center of the content viewport --><ion-fab center middle><button ion-fab>Button</button></ion-fab></ion-content>Ionic's FAB also supports "material design's fab speed dial". It is a normal fab button that shows a list of related actions when clicked.
The same
ion-fab
container can contain severalion-fab-list
with different side values:top
,bottom
,left
andright
. For example, if you want to have a list of button that are on the top of the main button, you should useside="top"
and so on. By default, if side is ommited,side="bottom"
.<ion-content><!-- this fab is placed at bottom right --><ion-fab bottom right ><button ion-fab>Share</button><ion-fab-list side="top"><button ion-fab>Facebook</button><button ion-fab>Twitter</button><button ion-fab>Youtube</button></ion-fab-list><ion-fab-list side="left"><button ion-fab>Vimeo</button></ion-fab-list></ion-fab></ion-content>A FAB speed dial can also be closed programatically.
<ion-content><ion-fab bottom right #fab><button ion-fab>Share</button><ion-fab-list side="top"><button ion-fab (click)="share('facebook', fab)">Facebook</button><button ion-fab (click)="share('twitter', fab)">Twitter</button></ion-fab-list></ion-fab></ion-content>share(socialNet: string, fab: FabContainer) {fab.close();console.log("Sharing in", socialNet);}/docs/demos/src/fab/
See Also
constructor
constructor(plt: Platform);
method canActivateList
canActivateList: (ev: any) => boolean;
method clickHandler
clickHandler: (ev: any) => void;
method close
close: () => void;
Close an active FAB list container
method ngAfterContentInit
ngAfterContentInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method setActiveLists
setActiveLists: (isActive: boolean) => void;
method toggleList
toggleList: () => void;
class FabList
class FabList {}
FabList
ion-fab-list
is a container for multiple FAB buttons. They are components ofion-fab
and allow you to specificy the buttons position, left, right, top, bottom.<ion-fab bottom right ><button ion-fab>Share</button><ion-fab-list side="top"><button ion-fab>Facebook</button><button ion-fab>Twitter</button><button ion-fab>Youtube</button></ion-fab-list><ion-fab-list side="left"><button ion-fab>Vimeo</button></ion-fab-list></ion-fab>ionic
/docs/demos/src/fab/
See Also
constructor
constructor( _elementRef: ElementRef, _renderer: Renderer, config: Config, _plt: Platform);
method setVisible
setVisible: (val: boolean) => void;
class Footer
class Footer extends Ion implements IFooter {}
Footer Footer is a root component of a page that sits at the bottom of the page. Footer can be a wrapper for
ion-toolbar
to make sure the content area is sized correctly.<ion-content></ion-content><ion-footer><ion-toolbar><ion-title>Footer</ion-title></ion-toolbar></ion-footer>
constructor
constructor( config: Config, elementRef: ElementRef, renderer: Renderer, viewCtrl: ViewController);
class Form
class Form {}
method deregister
deregister: (input: IonicFormInput) => void;
method nextId
nextId: () => number;
method register
register: (input: IonicFormInput) => void;
method setAsFocused
setAsFocused: (input: IonicFormInput) => void;
method tabFocus
tabFocus: (currentInput: IonicFormInput) => void;
Focuses the next input element, if it exists.
method unsetAsFocused
unsetAsFocused: (input: IonicFormInput) => void;
class Gesture
class Gesture {}
A gesture recognizer class.
TODO(mlynch): Re-enable the DOM event simulation that was causing issues (or verify hammer does this already, it might);
constructor
constructor(element: HTMLElement, opts?: any);
property direction
direction: string;
property element
element: HTMLElement;
property isListening
isListening: boolean;
method destroy
destroy: () => void;
method listen
listen: () => void;
method off
off: (type: string, cb: Function) => void;
method on
on: (type: string, cb: Function) => void;
method options
options: (opts: any) => void;
method unlisten
unlisten: () => void;
class GestureController
class GestureController {}
constructor
constructor(_app: App);
method canStart
canStart: (gestureName: string) => boolean;
method capture
capture: (gestureName: string, id: number, priority: number) => boolean;
method createBlocker
createBlocker: (opts?: BlockerOptions) => BlockerDelegate;
method createGesture
createGesture: (opts: GestureOptions) => GestureDelegate;
method disableGesture
disableGesture: (gestureName: string, id: number) => void;
method disableScroll
disableScroll: (id: number) => void;
method enableGesture
enableGesture: (gestureName: string, id: number) => void;
method enableScroll
enableScroll: (id: number) => void;
method isCaptured
isCaptured: () => boolean;
method isDisabled
isDisabled: (gestureName: string) => boolean;
method isScrollDisabled
isScrollDisabled: () => boolean;
method newID
newID: () => number;
method release
release: (id: number) => void;
method start
start: (gestureName: string, id: number, priority: number) => boolean;
class GestureDelegate
class GestureDelegate {}
constructor
constructor( name: string, id: number, controller: GestureController, priority: number, disableScroll: boolean);
method canStart
canStart: () => boolean;
method capture
capture: () => boolean;
method destroy
destroy: () => void;
method release
release: () => void;
method start
start: () => boolean;
class Grid
class Grid {}
Grid ionic
The grid is a powerful mobile-first flexbox system for building custom layouts. It is heavily influenced by [Bootstrap's grid system](http://v4-alpha.getbootstrap.com/layout/grid/).
The grid is composed of three units — a grid, row(s) and column(s). Columns will expand to fill their row, and will resize to fit additional columns. It is based on a 12 column layout with different breakpoints based on the screen size. The number of columns and breakpoints can be fully customized using Sass.
- [How it works](#how-it-works) - [Grid size](#grid-size) - [Grid attributes](#grid-attributes) - [Default breakpoints](#default-breakpoints) - [Auto-layout columns](#auto-layout-columns) - [Equal-width](#equal-width) - [Setting one column width](#setting-one-column-width) - [Variable-width](#variable-width) - [Responsive attributes](#responsive-attributes) - [All breakpoints](#all-breakpoints) - [Stacked to horizontal](#stacked-to-horizontal) - [Reordering](#reordering) - [Offsetting columns](#offsetting-columns) - [Push and pull](#push-and-pull) - [Alignment](#alignment) - [Vertical Alignment](#vertical-alignment) - [Horizontal Alignment](#horizontal-alignment) - [Customizing the grid](#customizing-the-grid) - [Number of columns and padding](#number-of-columns-and-padding) - [Grid tiers](#grid-tiers)
## How it works
The grid is a mobile-first system made up of any number of rows and columns. It is built with flexbox making it extremely responsive. The components that make up the grid can be written as an element (e.g.,
<ion-grid>
) or added as an attribute to any element (e.g.,<div ion-row>
).Here's how it works:
- Grids act as a container for all rows and columns. Grids take up the full width of their container, but adding the
fixed
attribute will specify the width per screen size, see [grid size](#grid-size) below. - Rows are horizontal groups of columns that line the columns up properly. - Content should be placed within columns, and only columns may be immediate children of rows. - Grid columns without a specified width will automatically have equal widths. For example, four instances ofcol-sm
will each automatically be 25% wide for small breakpoints. - Column attributes indicate the number of columns to use out of the default 12 per row. So,col-4
can be added in order to have three equal-width columns. - Column widths are set as a percentage, so they’re always fluid and sized relative to their parent element. - Columns have padding between individual columns, however, the padding can be removed from the grid and columns by addingno-padding
on the grid. - There are five grid tiers by default, one for each responsive breakpoint: all breakpoints (extra small), small, medium, large, and extra large. - Grid tiers are based on minimum widths, meaning they apply to their tier and all those larger than it (e.g.,col-sm-4
applies to small, medium, large, and extra large devices). - Grids can easily be customized via Sass variables. See [customizing the grid](#customizing-the-grid).There are some [known bugs with flexbox](https://github.com/philipwalton/flexbugs) that should be checked prior to creating issues with Ionic.
## Grid size
By default, the grid will take up 100% width. To set a maximum width based on the screen size add the
fixed
attribute. The maximum width of the grid for each breakpoint is defined in the$grid-max-widths
Sass variable. For more information, see [customizing the grid](#customizing-the-grid).| Name | Value | Description | |----------|----------|-----------------------------------------------------| | xs | auto | Don't set the grid width for xs screens | | sm | 540px | Set grid width to 540px when (min-width: 576px) | | md | 720px | Set grid width to 720px when (min-width: 768px) | | lg | 960px | Set grid width to 960px when (min-width: 992px) | | xl | 1140px | Set grid width to 1140px when (min-width: 1200px) |
## Grid attributes
The grid takes up full width and has padding added to it based on the screen size. There are two attributes that can be used to adjust this behavior.
| Property | Description | |-----------------|-------------------------------------------------------------------------------------------------------------------| | no-padding | Removes padding from the grid and immediate children columns. | | fixed | Set a max width based on the screen size. |
## Default breakpoints
The default breakpoints are defined by the
$grid-breakpoints
Sass variable. It can be customized to use different values for the breakpoint, rename and add/remove breakpoints. For more information, see [customizing the grid](#customizing-the-grid).| Name | Value | Width Prefix | Offset Prefix | Push Prefix | Pull Prefix | Description | |----------|----------|--------------|---------------|--------------|-------------|---------------------------------------------------| | xs | 0 |
col-
|offset-
|push-
|pull-
| Set columns when (min-width: 0) | | sm | 576px |col-sm-
|offset-sm-
|push-sm-
|pull-sm-
| Set columns when (min-width: 576px) | | md | 768px |col-md-
|offset-md-
|push-md-
|pull-md-
| Set columns when (min-width: 768px) | | lg | 992px |col-lg-
|offset-lg-
|push-lg-
|pull-lg-
| Set columns when (min-width: 992px) | | xl | 1200px |col-xl-
|offset-xl-
|push-xl-
|pull-xl-
| Set columns when (min-width: 1200px) |_Note: the first breakpoint must have the value set to 0 and all breakpoint values must be in ascending order._
## Auto-layout columns
### Equal-width
By default, columns will take up equal width inside of a row for all devices and screen sizes.
<ion-grid><ion-row><ion-col>1 of 2</ion-col><ion-col>2 of 2</ion-col></ion-row><ion-row><ion-col>1 of 3</ion-col><ion-col>2 of 3</ion-col><ion-col>3 of 3</ion-col></ion-row></ion-grid>### Setting one column width
Set the width of one column and the others will automatically resize around it. This can be done using our predefined grid attributes. In the example below, the other columns will resize no matter the width of the center column.
<ion-grid><ion-row><ion-col>1 of 3</ion-col><ion-col col-8>2 of 3 (wider)</ion-col><ion-col>3 of 3</ion-col></ion-row><ion-row><ion-col>1 of 3</ion-col><ion-col col-6>2 of 3 (wider)</ion-col><ion-col>3 of 3</ion-col></ion-row></ion-grid>### Variable-width
Using the
col-{breakpoint}-auto
attributes, the column can size itself based on the natural width of its content. This is extremely useful for setting a column width using pixels. The columns next to the variable-width column will resize to fill the row.<ion-grid><ion-row><ion-col>1 of 3</ion-col><ion-col col-auto>Variable width content</ion-col><ion-col>3 of 3</ion-col></ion-row><ion-row><ion-col>1 of 4</ion-col><ion-col>2 of 4</ion-col><ion-col col-auto><ion-input placeholder="Variable width input"></ion-input></ion-col><ion-col>4 of 4</ion-col></ion-row></ion-grid>## Responsive attributes
### All breakpoints
To customize a column's width for all devices and screens, add the
col-*
attribute. These attributes tell the column to take up*
columns out of the available columns.<ion-grid><ion-row><ion-col col-4>1 of 4</ion-col><ion-col col-2>2 of 4</ion-col><ion-col col-2>3 of 4</ion-col><ion-col col-4>4 of 4</ion-col></ion-row></ion-grid>### Stacked to horizontal
Use a combination of width and breakpoint attributes to create a grid that starts out stacked on extra small screens before becoming horizontal on small screens.
<ion-grid><ion-row><ion-col col-12 col-sm>1 of 4</ion-col><ion-col col-12 col-sm>2 of 4</ion-col><ion-col col-12 col-sm>3 of 4</ion-col><ion-col col-12 col-sm>4 of 4</ion-col></ion-row></ion-grid>## Reordering
### Offsetting columns
Move columns to the right by adding the
offset-*
attributes. These attributes increase the margin start of the column by*
columns. For example, in the following grid the last column will be offset by 3 columns and take up 3 columns:<ion-grid><ion-row><ion-col col-3>1 of 2</ion-col><ion-col col-3 offset-3>2 of 2</ion-col></ion-row></ion-grid>Offsets can also be added based on screen breakpoints. Here's an example of a grid where the last column will be offset by 3 columns for
md
screens and up:<ion-grid><ion-row><ion-col col-md-3>1 of 3</ion-col><ion-col col-md-3>2 of 3</ion-col><ion-col col-md-3 offset-md-3>3 of 3</ion-col></ion-row></ion-grid>### Push and pull
Reorder the columns by adding the
push-*
andpull-*
attributes. These attributes adjust theleft
andright
of the columns by*
columns making it easy to reorder columns. For example, in the following grid the column with the1st col
description will actually be the last column and the2nd col
will be the first column.<ion-grid><ion-row><ion-col col-9 push-3>1 of 2</ion-col><ion-col col-3 pull-9>2 of 2</ion-col></ion-row></ion-grid>Push and pull can also be added based on screen breakpoints. In the following example, the column with the
3rd
column description will actually be the first column formd
screens and up:<ion-grid><ion-row><ion-col col-md-6 push-md-3>1 of 3</ion-col><ion-col col-md-3 push-md-3>2 of 3</ion-col><ion-col col-md-3 pull-md-9>3 of 3</ion-col></ion-row></ion-grid>## Alignment
### Vertical alignment
All columns can be vertically aligned inside of a row by adding different attributes to the row. For a list of available attributes, see [row attributes](../Row#row-attributes).
<ion-grid><ion-row align-items-start><ion-col>1 of 4</ion-col><ion-col>2 of 4</ion-col><ion-col>3 of 4</ion-col><ion-col>4 of 4 <br>#<br>#<br>#</ion-col></ion-row><ion-row align-items-center><ion-col>1 of 4</ion-col><ion-col>2 of 4</ion-col><ion-col>3 of 4</ion-col><ion-col>4 of 4 <br>#<br>#<br>#</ion-col></ion-row><ion-row align-items-end><ion-col>1 of 4</ion-col><ion-col>2 of 4</ion-col><ion-col>3 of 4</ion-col><ion-col>4 of 4 <br>#<br>#<br>#</ion-col></ion-row></ion-grid>Columns can also align themselves differently than other columns by adding the alignment attribute directly to the column. For a list of available attributes, see [column attributes](../Col#column-attributes).
<ion-grid><ion-row><ion-col align-self-start><div>1 of 4</div></ion-col><ion-col align-self-center><div>2 of 4</div></ion-col><ion-col align-self-end><div>3 of 4</div></ion-col><ion-col><div>4 of 4 <br>#<br>#<br>#</div></ion-col></ion-row></ion-grid>### Horizontal alignment
All columns can be horizontally aligned inside of a row by adding different attributes to the row. For a list of available attributes, see [row attributes](../Row#row-attributes).
<ion-grid><ion-row justify-content-start><ion-col col-3>1 of 2</ion-col><ion-col col-3>2 of 2</ion-col></ion-row><ion-row justify-content-center><ion-col col-3>1 of 2</ion-col><ion-col col-3>2 of 2</ion-col></ion-row><ion-row justify-content-end><ion-col col-3>1 of 2</ion-col><ion-col col-3>2 of 2</ion-col></ion-row><ion-row justify-content-around><ion-col col-3>1 of 2</ion-col><ion-col col-3>2 of 2</ion-col></ion-row><ion-row justify-content-between><ion-col col-3>1 of 2</ion-col><ion-col col-3>2 of 2</ion-col></ion-row></ion-grid>## Customizing the grid
Using our built-in grid Sass variables and maps, it’s possible to completely customize the predefined grid attributes. Change the number of breakpoints, the media query values, the number of columns, and more.
### Number of columns and padding
The number of grid columns and their padding can be modified via Sass variables.
$grid-columns
is used to generate the widths (in percent) of each individual column.$grid-padding-width
is used for the padding on the grid, while$grid-padding-widths
allows breakpoint-specific widths that are divided evenly acrosspadding-left
andpadding-right
as well aspadding-top
andpadding-bottom
of the grid and columns.$grid-columns: 12 !default;$grid-padding-width: 10px !default;$grid-padding-widths: (xs: $grid-padding-width,sm: $grid-padding-width,md: $grid-padding-width,lg: $grid-padding-width,xl: $grid-padding-width) !default;### Grid tiers
To customize the breakpoints and their values, override the values of
$grid-breakpoints
and$grid-max-widths
. For example, to only use 3 breakpoints, the following could be written:$grid-breakpoints: (sm: 0,md: 768px,lg: 1024px);$grid-max-widths: (sm: 420px,md: 720px,lg: 960px);
class Haptic
class Haptic {}
Haptic The
Haptic
class interacts with a haptic engine on the device, if available. Generally, Ionic components use this under the hood, but you're welcome to get a bit crazy with it if you fancy.Currently, this uses the Taptic engine on iOS.
export class MyClass {constructor(haptic: Haptic) {haptic.selection();}}
constructor
constructor(plt: Platform);
method available
available: () => boolean;
Check to see if the Haptic Plugin is available {boolean} Returns true or false if the plugin is available
method gestureSelectionChanged
gestureSelectionChanged: () => void;
Tell the haptic engine that a selection changed during a gesture.
method gestureSelectionEnd
gestureSelectionEnd: () => void;
Tell the haptic engine we are done with a gesture. This needs to be called lest resources are not properly recycled.
method gestureSelectionStart
gestureSelectionStart: () => void;
Tell the haptic engine that a gesture for a selection change is starting.
method impact
impact: (options: { style: string }) => void;
Use this to indicate success/failure/warning to the user. options should be of the type
{ style: 'light' }
(ormedium
/heavy
)
method notification
notification: (options: { type: string }) => void;
Use this to indicate success/failure/warning to the user. options should be of the type
{ type: 'success' }
(orwarning
/error
)
method selection
selection: () => void;
Trigger a selection changed haptic event. Good for one-time events (not for gestures)
class Header
class Header extends Ion implements IHeader {}
Header Header is a parent component that holds the navbar and toolbar component. It's important to note that
ion-header
needs to be one of the three root elements of a page<ion-header><ion-navbar><ion-title>Page1</ion-title></ion-navbar><ion-toolbar><ion-title>Subheader</ion-title></ion-toolbar></ion-header><ion-content></ion-content>
constructor
constructor( config: Config, elementRef: ElementRef, renderer: Renderer, viewCtrl: ViewController);
class HideWhen
class HideWhen extends DisplayWhen {}
HideWhen The
hideWhen
attribute takes a string that represents a plaform or screen orientation. The element the attribute is added to will only be hidden when that platform or screen orientation is active.Complements the [showWhen attribute](../ShowWhen). If the
hideWhen
attribute is used on an element that also has theshowWhen
attribute, the element will not show ifhideWhen
evaluates totrue
orshowWhen
evaluates tofalse
. If thehidden
attribute is also added, the element will not show ifhidden
evaluates totrue
.View the [Platform API docs](../../../platform/Platform) for more information on the different platforms you can use.
<div hideWhen="android">I am hidden on Android!</div><div hideWhen="ios">I am hidden on iOS!</div><div hideWhen="android,ios">I am hidden on Android and iOS!</div><div hideWhen="portrait">I am hidden on Portrait!</div><div hideWhen="landscape">I am hidden on Landscape!</div>/docs/demos/src/hide-when/
See Also
constructor
constructor(hideWhen: string, plt: Platform, zone: NgZone);
class Icon
class Icon extends Ion {}
Icon Icons can be used on their own, or inside of a number of Ionic components. For a full list of available icons, check out the [Ionicons docs](../../../../ionicons).
One feature of Ionicons in Ionic is when icon names are set, the actual icon which is rendered can change slightly depending on the mode the app is running from. For example, by setting the icon name of
alarm
, on iOS the icon will automatically applyios-alarm
, and on Material Design it will automatically applymd-alarm
. This allows the developer to write the markup once while Ionic applies the appropriate icon based on the mode.<!-- automatically uses the correct "star" icon depending on the mode --><ion-icon name="star"></ion-icon><!-- explicity set the icon for each mode --><ion-icon ios="ios-home" md="md-home"></ion-icon><!-- always use the same icon, no matter what the mode --><ion-icon name="ios-clock"></ion-icon><ion-icon name="logo-twitter"></ion-icon>/docs/demos/src/icon/
See Also
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
property ios
ios: string;
{string} Specifies which icon to use on
ios
mode.
property isActive
isActive: boolean;
{boolean} If true, the icon is styled with an "active" appearance. An active icon is filled in, and an inactive icon is the outline of the icon. The
isActive
property is largely used by the tabbar. Only affectsios
icons.
property md
md: string;
{string} Specifies which icon to use on
md
mode.
property name
name: string;
{string} Specifies which icon to use. The appropriate icon will be used based on the mode. For more information, see [Ionicons](/docs/ionicons/).
method ngOnDestroy
ngOnDestroy: () => void;
method update
update: () => void;
class Img
class Img implements OnDestroy, IImg {}
Img Two of the biggest cuprits of scroll jank is starting up a new HTTP request, and rendering images. These two reasons is largely why
ion-img
was created. The standard HTMLimg
element is often a large source of these problems, and what makes matters worse is that the app does not have fine-grained control of requests and rendering for eachimg
element.The
ion-img
component is similar to the standardimg
element, but it also adds features in order to provide improved performance. Features include only loading images which are visible, using web workers for HTTP requests, preventing jank while scrolling and in-memory caching.Note that
ion-img
also comes with a few more restrictions in comparison to the standardimg
element. A good rule is, if there are only a few images to be rendered on a page, then the standardimg
is probably best. However, if a page has the potential for hundreds or even thousands of images within a scrollable area, thenion-img
would be better suited for the job.> Note:
ion-img
is only meant to be used inside of [virtual-scroll](/docs/api/components/virtual-scroll/VirtualScroll/)### Lazy Loading
Lazy loading images refers to only loading images which are actually visible within the user's viewport. This also means that images which are not viewable on the initial load would not be downloaded or rendered. Next, as the user scrolls, each image which becomes visible is then requested then rendered on-demand.
The benefits of this approach is that unnecessary and resource intensive HTTP requests are not started, valuable bandwidth isn't wasted, and this allows the browser to free up resources which would be wasted on images which are not even viewable. For example, animated GIFs are enourmous performance drains, however, with
ion-img
the app is able to dedicate resources to just the viewable images. But again, if the problems listed above are not problems within your app, then the standardimg
element may be best.### Image Dimensions
By providing image dimensions up front, Ionic is able to accurately size up the image's location within the viewport, which helps lazy load only images which are viewable. Image dimensions can either by set as properties, inline styles, or external stylesheets. It doesn't matter which method of setting dimensions is used, but it's important that somehow each
ion-img
has been given an exact size.For example, by default
<ion-avatar>
and<ion-thumbnail>
already come with exact sizes when placed within an<ion-item>
. By giving each image an exact size, this then further locks in the size of eachion-item
, which again helps improve scroll performance.<!-- dimensions set using attributes --><ion-img width="80" height="80" src="..."></ion-img><!-- dimensions set using input properties --><ion-img [width]="imgWidth" [height]="imgHeight" src="..."></ion-img><!-- dimensions set using inline styles --><ion-img style="width: 80px; height: 80px;" src="..."></ion-img>Additionally, each
ion-img
uses theobject-fit: cover
CSS property. What this means is that the actual rendered image will center itself within it's container. Or to really get detailed: The image is sized to maintain its aspect ratio while filling the containing element’s entire content box. Its concrete object size is resolved as a cover constraint against the element’s used width and height.### Future Optimizations
Future goals are to place image requests within web workers, and cache images in-memory as datauris. This method has proven to be effective, however there are some current limitations with Cordova which we are currently working on.
constructor
constructor( _elementRef: ElementRef, _renderer: Renderer, _plt: Platform, _content: Content, _dom: DomController);
property alt
alt: string;
{string} Set the
alt
attribute which gets assigned to the innerimg
element.
property bottom
readonly bottom: number;
property bounds
bounds: any;
{any} Sets the bounding rectangle of the element relative to the viewport. When using
VirtualScroll
, each virtual item should pass its bounds to eachion-img
. The passed in data object should includetop
andbottom
properties.
property cache
cache: boolean;
{boolean} After an image has been successfully downloaded, it can be cached in-memory. This is useful for
VirtualScroll
by allowing image responses to be cached, and not rendered, until after scrolling has completed, which allows for smoother scrolling.
property canRender
canRender: boolean;
property canRequest
canRequest: boolean;
property height
height: string | number;
{string} Image height. If this property is not set it's important that the dimensions are still set using CSS. If the dimension is just a number it will assume the
px
unit.
property src
src: string;
{string} The source of the image.
property top
readonly top: number;
property width
width: string | number;
{string} Image width. If this property is not set it's important that the dimensions are still set using CSS. If the dimension is just a number it will assume the
px
unit.
method ngAfterContentInit
ngAfterContentInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method reset
reset: () => void;
method update
update: () => void;
class InfiniteScroll
class InfiniteScroll {}
InfiniteScroll The Infinite Scroll allows you to perform an action when the user scrolls a specified distance from the bottom or top of the page.
The expression assigned to the
infinite
event is called when the user scrolls to the specified distance. When this expression has finished its tasks, it should call thecomplete()
method on the infinite scroll instance.<ion-content><ion-list><ion-item *ngFor="let i of items">{% raw %}{{i}}{% endraw %}</ion-item></ion-list><ion-infinite-scroll (ionInfinite)="doInfinite($event)"><ion-infinite-scroll-content></ion-infinite-scroll-content></ion-infinite-scroll></ion-content>@Component({...})export class NewsFeedPage {items = [];constructor() {for (let i = 0; i < 30; i++) {this.items.push( this.items.length );}}doInfinite(infiniteScroll) {console.log('Begin async operation');setTimeout(() => {for (let i = 0; i < 30; i++) {this.items.push( this.items.length );}console.log('Async operation has ended');infiniteScroll.complete();}, 500);}}##
waitFor
method of InfiniteScrollIn case if your async operation returns promise you can utilize
waitFor
method inside your template.<ion-content><ion-list><ion-item *ngFor="let item of items">{{item}}</ion-item></ion-list><ion-infinite-scroll (ionInfinite)="$event.waitFor(doInfinite())"><ion-infinite-scroll-content></ion-infinite-scroll-content></ion-infinite-scroll></ion-content>@Component({...})export class NewsFeedPage {items = [];constructor() {for (var i = 0; i < 30; i++) {this.items.push( this.items.length );}}doInfinite(): Promise<any> {console.log('Begin async operation');return new Promise((resolve) => {setTimeout(() => {for (var i = 0; i < 30; i++) {this.items.push( this.items.length );}console.log('Async operation has ended');resolve();}, 500);})}}## Infinite Scroll Content
By default, Ionic uses the infinite scroll spinner that looks best for the platform the user is on. However, you can change the default spinner or add text by adding properties to the
ion-infinite-scroll-content
component.```html
<ion-infinite-scroll (ionInfinite)="doInfinite($event)">
```
## Further Customizing Infinite Scroll Content
The
ion-infinite-scroll
component holds the infinite scroll logic. It requires a child component in order to display the content. Ionic usesion-infinite-scroll-content
by default. This component displays the infinite scroll and changes the look depending on the infinite scroll's state. Separating these components allows developers to create their own infinite scroll content components. You could replace our default content with custom SVG or CSS animations./docs/demos/src/infinite-scroll/
constructor
constructor( _content: Content, _zone: NgZone, _elementRef: ElementRef, _dom: DomController);
property enabled
enabled: boolean;
{boolean} If true, Whether or not the infinite scroll should be enabled or not. Setting to
false
will remove scroll event listeners and hide the display.
property ionInfinite
ionInfinite: EventEmitter<InfiniteScroll>;
{event} Emitted when the scroll reaches the threshold distance. From within your infinite handler, you must call the infinite scroll's
complete()
method when your async operation has completed.
property position
position: string;
{string} The position of the infinite scroll element. The value can be either
top
orbottom
. Default isbottom
.
property threshold
threshold: string;
{string} The threshold distance from the bottom of the content to call the
infinite
output event when scrolled. The threshold value can be either a percent, or in pixels. For example, use the value of10%
for theinfinite
output event to get called when the user has scrolled 10% from the bottom of the page. Use the value100px
when the scroll is within 100 pixels from the bottom of the page. Default is15%
.
method complete
complete: () => void;
Call
complete()
within theinfinite
output event handler when your async operation has completed. For example, theloading
state is while the app is performing an asynchronous operation, such as receiving more data from an AJAX request to add more items to a data list. Once the data has been received and UI updated, you then call this method to signify that the loading has completed. This method will change the infinite scroll's state fromloading
toenabled
.
method enable
enable: (shouldEnable: boolean) => void;
Call
enable(false)
to disable the infinite scroll from actively trying to receive new data while scrolling. This method is useful when it is known that there is no more data that can be added, and the infinite scroll is no longer needed.Parameter shouldEnable
If the infinite scroll should be enabled or not. Setting to
false
will remove scroll event listeners and hide the display.
method ngAfterContentInit
ngAfterContentInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method waitFor
waitFor: (action: Promise<any>) => void;
Pass a promise inside
waitFor()
within theinfinite
output event handler in order to change state of infiniteScroll to "complete"
class InfiniteScrollContent
class InfiniteScrollContent {}
constructor
constructor(inf: InfiniteScroll, _config: Config);
property inf
inf: InfiniteScroll;
property loadingSpinner
loadingSpinner: string;
{string} An animated SVG spinner that shows while loading.
property loadingText
loadingText: string;
{string} Optional text to display while loading.
method ngOnInit
ngOnInit: () => void;
class Ion
class Ion {}
constructor
constructor( config: Config, elementRef: ElementRef, renderer: Renderer, componentName?: string);
property color
color: string;
{string} The color to use from your Sass
$colors
map. Default options are:"primary"
,"secondary"
,"danger"
,"light"
, and"dark"
. For more information, see [Theming your App](/docs/theming/theming-your-app).
property mode
mode: string;
{string} The mode determines which platform styles to use. Possible values are:
"ios"
,"md"
, or"wp"
. For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
method getElementRef
getElementRef: () => ElementRef;
method getNativeElement
getNativeElement: () => any;
method setElementAttribute
setElementAttribute: (attributeName: string, attributeValue: any) => void;
method setElementClass
setElementClass: (className: string, isAdd: boolean) => void;
method setElementStyle
setElementStyle: (property: string, value: string) => void;
class IonicApp
class IonicApp extends Ion implements OnInit {}
constructor
constructor( _userCmp: any, _cfr: ComponentFactoryResolver, elementRef: ElementRef, renderer: Renderer, config: Config, _plt: Platform, app: App);
method ngOnInit
ngOnInit: () => void;
method stopScroll
stopScroll: () => Promise<boolean>;
class IonicErrorHandler
class IonicErrorHandler extends ErrorHandler {}
IonicErrorHandler The
IonicErrorHandler
intercepts the defaultConsole
error handling and displays runtime errors as an overlay when using Ionic's Dev Build Server.### IonicErrorHandler Example
import { ErrorHandler, NgModule } from '@angular/core';import { IonicErrorHandler } from 'ionic-angular';@NgModule({providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }]})class AppModule { }### Custom Error Handlers
Custom error handlers can be built to replace the default, or extend Ionic's error handler.
class MyErrorHandler implements ErrorHandler {handleError(err: any): void {// do something with the error}}@NgModule({providers: [{ provide: ErrorHandler, useClass: MyErrorHandler }]})class AppModule { }More information about Angular's [
ErrorHandler
](https://angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html).
constructor
constructor();
class IonicFormInput
abstract class IonicFormInput {}
method initFocus
abstract initFocus: () => void;
class IonicGestureConfig
class IonicGestureConfig extends HammerGestureConfig {}
This class overrides the default Angular gesture config.
method buildHammer
buildHammer: (element: HTMLElement) => any;
class IonicModule
class IonicModule {}
IonicModule IonicModule is an [NgModule](https://angular.io/docs/ts/latest/guide/ngmodule.html) that bootstraps an Ionic App. By passing a root component, IonicModule will make sure that all of the components, directives, and providers from the framework are imported.
Any configuration for the app can be passed as the second argument to
forRoot
. This can be any valid property from the [Config](/docs/api/config/Config/).import { NgModule } from '@angular/core';import { IonicApp, IonicModule } from 'ionic-angular';import { MyApp } from './app.component';import { HomePage } from '../pages/home/home';@NgModule({declarations: [MyApp,HomePage],imports: [BrowserModule,IonicModule.forRoot(MyApp, {})],bootstrap: [IonicApp],entryComponents: [MyApp,HomePage],providers: []})export class AppModule {}
method forRoot
static forRoot: ( appRoot: any, config?: any, deepLinkConfig?: DeepLinkConfig) => ModuleWithProviders;
Set the root app component for you IonicModule
Parameter appRoot
The root AppComponent for this app.
Parameter config
Config Options for the app. Accepts any config property.
Parameter deepLinkConfig
Any configuration needed for the Ionic Deeplinker.
class IonicPageModule
class IonicPageModule {}
IonicPageModule IonicPageModule is an [NgModule](https://angular.io/docs/ts/latest/guide/ngmodule.html) that bootstraps a child [IonicPage](../navigation/IonicPage/) in order to set up routing.
import { NgModule } from '@angular/core';import { IonicPageModule } from 'ionic-angular';import { HomePage } from './home';@NgModule({declarations: [HomePage],imports: [IonicPageModule.forChild(HomePage)],entryComponents: [HomePage]})export class HomePageModule { }
method forChild
static forChild: (page: any) => ModuleWithProviders;
class IonicTapInput
abstract class IonicTapInput implements IonicFormInput {}
class Item
class Item extends Ion {}
Item An item can contain text, images, and anything else. Generally it is placed in a list with other items. It can easily be swiped, deleted, reordered, edited, and more. An item is only required to be in a [List](../../list/List) if manipulating the item via gestures is required. It requires an [ItemSliding](../ItemSliding) wrapper element in order to be swiped.
## Common Usage There are a few elements that are considered items, but not all of them are styled to look the same. The basic item can be written as an
<ion-item>
element or it can be added to any element by addingion-item
as an attribute. List headers and item dividers, although styled differently, are also items and can be written as<ion-list-header>
and<ion-item-divider>
, respectively.### As an Element A basic item should be written as a
<ion-item>
element when it is not clickable.<ion-item>Item</ion-item>A list header should be written as
<ion-list-header>
.<ion-list-header>List Header</ion-list-header>An item divider should be written as
<ion-item-divider>
.<ion-item-divider>Item Divider</ion-item-divider>### As an Attribute The attribute
ion-item
should be added to a<button>
when the item can be clicked or tapped. It should be added to an<a>
element when the item needs to contain ahref
. It can be added as an attribute to any element to take on the item styling.<button ion-item (click)="buttonClick()">Button Item</button><a ion-item href="https://www.ionicframework.com">Anchor Item</a>Note: do not add
ion-item
as an attribute to an<ion-list-header>
or<ion-item-divider>
element as they are already items and their styling will be changed to look like a basic item.## Detail Arrows By default,
<button>
and<a>
elements with theion-item
attribute will display a right arrow icon onios
mode. To hide the right arrow icon on either of these elements, add thedetail-none
attribute to the item. To show the right arrow icon on an element that doesn't display it naturally, add thedetail-push
attribute to the item.<ion-item detail-push>Item with Detail Arrow</ion-item><button ion-item (click)="buttonClick()">Button Item with Detail Arrow</button><a ion-item detail-none href="https://www.ionicframework.com">Anchor Item with no Detail Arrow</a>This feature is not enabled by default for
md
andwp
modes, but it can be enabled by setting the Sass variables$item-md-detail-push-show
and$item-wp-detail-push-show
, respectively, totrue
. It can also be disabled for ios by setting$item-ios-detail-push-show
tofalse
. See the [theming documentation](http://ionicframework.com/docs/theming/overriding-ionic-variables/) for more information on overriding Sass variables.## Item Placement Items rely heavily on content projection to position content. The item grabs content based on the element or attribute and positions it that way. This logic makes it possible to write a complex item with simple, understandable markup without having to worry about styling and positioning the elements.
The below chart details the attributes item looks for and where it will place the element with that attribute inside of the item:
| Attribute | Description | |----------------|----------------------------------------------------------------------------------------------------- | |
item-start
| Placed to the left of all other elements, outside of the inner item. | |item-end
| Placed to the right of all other elements, inside of the inner item, outside of the input wrapper. | |item-content
| Placed to the right of anyion-label
, inside of the input wrapper. |### Checkboxes, Radios and Toggles [Checkboxes](../../checkbox/Checkbox) are positioned in the same place as the
item-start
attribute. [Radios](../../radio/RadioButton) and [Toggles](../../toggle/Toggle) are positioned in the same place as theitem-end
attribute. All of these components can be positioned differently by adding theitem-start
oritem-end
attribute.### Content and Inputs A [Label](../../label/Label) is placed inside of the item to the left of all content and inputs. The following components are all placed in the same position as the
item-content
attribute: [Select](../../select/Select), [Input](../../input/Input), [TextArea](../../input/TextArea), [DateTime](../../datetime/DateTime), and [Range](../../range/Range).Any element directly placed inside of an
<ion-item>
that does not have one of the previously mentioned attributes and isn't one of the above elements will be placed inside of a [Label](../../label/Label).### Text Alignment By default, Items will align text to the left and add an ellipsis when the text is wider than the item. See the [Utility Attributes Documentation](../../../../theming/css-utilities/) for attributes that can be added to
ion-item
to transform the text.<ion-list><ion-list-header>Header</ion-list-header><ion-item>Item</ion-item><ion-item detail-push>Item with Detail Arrow</ion-item><button ion-item (click)="buttonClick()">Button Item</button><ion-item-divider>Item Divider</ion-item-divider><button ion-item detail-none (click)="buttonClick()">Button Item with no Detail Arrow</button><a ion-item href="https://www.ionicframework.com">Anchor Item</a><ion-item no-lines>Item with no border</ion-item><ion-item text-wrap>Multiline text that should wrap when it is too longto fit on one line in the item.</ion-item></ion-list><ion-list><!-- List header with buttons on each side --><ion-list-header><button ion-button item-start (click)="buttonClick()">Button</button>List Header<button ion-button outline item-end (click)="buttonClick()">Outline</button></ion-list-header><!-- Loops through and creates multiple items --><ion-item *ngFor="let item of items">Item {% raw %}{{item}}{% endraw %}</ion-item><!-- Button item with an icon on the left --><button ion-item><ion-icon name="star" item-start></ion-icon>Button Item</button><!-- Item with a label and content --><ion-item><ion-label>Item Label</ion-label><div item-content>Item Content next to the label</div></ion-item><!-- Item with left and right buttons --><ion-item><button ion-button item-start (click)="buttonClick()">Button</button>Item<button ion-button outline item-end (click)="buttonClick()">Outline</button></ion-item><!-- Item divider with a right button --><ion-item-divider>Item Divider<button ion-button item-end>Button</button></ion-item-divider><!-- Disabled button item with left and right buttons --><button ion-item disabled><button ion-button item-start (click)="buttonClick()"><ion-icon name="home"></ion-icon>Left Icon</button>Disabled Button Item<button ion-button outline item-end (click)="buttonClick()"><ion-icon name="star"></ion-icon>Left Icon</button></button><!-- Item with an avatar on the left and button on the right --><ion-item><ion-avatar item-start><img src="img/my-avatar.png"></ion-avatar>Avatar Item<button ion-button outline item-end>View</button></ion-item><!-- Item with a thumbnail on the right --><ion-item><h2>Item</h2><p>Item Paragraph</p><ion-thumbnail item-end><img src="img/my-thumbnail.png"></ion-thumbnail></ion-item><!-- Sliding item --><ion-item-sliding><ion-item>Item</ion-item><ion-item-options><button ion-button color="primary" (click)="archive()">Archive</button></ion-item-options></ion-item-sliding></ion-list>/docs/demos/src/item/
See Also
constructor
constructor( form: Form, config: Config, elementRef: ElementRef, renderer: Renderer, reorder: ItemReorder);
property contentLabel
contentLabel: Label;
property id
id: string;
property labelId
labelId: string;
property viewLabel
viewLabel: Label;
method getLabelText
getLabelText: () => string;
method ngAfterContentInit
ngAfterContentInit: () => void;
method registerInput
registerInput: (type: string) => string;
class ItemContent
class ItemContent {}
class ItemDivider
class ItemDivider extends Ion {}
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class ItemGroup
class ItemGroup {}
class ItemOptions
class ItemOptions {}
ItemOptions The option buttons for an
ion-item-sliding
. These buttons can be placed either on the left or right side. You can combine the(ionSwipe)
event plus theexpandable
directive to create a full swipe action for the item.<ion-item-sliding><ion-item>Item 1</ion-item><ion-item-options side="right" (ionSwipe)="saveItem(item)"><button ion-button expandable (click)="saveItem(item)"><ion-icon name="star"></ion-icon></button></ion-item-options></ion-item-sliding>
constructor
constructor(_elementRef: ElementRef, _plt: Platform);
property ionSwipe
ionSwipe: EventEmitter<ItemSliding>;
{event} Emitted when the item has been fully swiped.
property side
side: Side;
{string} The side the option button should be on. Defaults to
"right"
. If you have multipleion-item-options
, a side must be provided for each.
method isRightSide
isRightSide: () => boolean;
method width
width: () => any;
class ItemReorder
class ItemReorder implements ItemReorderGestureDelegate {}
ItemReorder Item reorder adds the ability to change an item's order in a group. It can be used within an
ion-list
orion-item-group
to provide a visual drag and drop interface.## Grouping Items
All reorderable items must be grouped in the same element. If an item should not be reordered, it shouldn't be included in this group. For example, the following code works because the items are grouped in the
<ion-list>
:```html <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %} ```
However, the below list includes a header that shouldn't be reordered:
```html Header <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %} ```
In order to mix different sets of items,
ion-item-group
should be used to group the reorderable items:```html Header <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %} ```
It's important to note that in this example, the
[reorder]
directive is applied to the<ion-item-group>
instead of the<ion-list>
. This way makes it possible to mix items that should and shouldn't be reordered.## Implementing the Reorder Function
When the item is dragged and dropped into the new position, the
(ionItemReorder)
event is emitted. This event provides the initial index (from) and the new index (to) of the reordered item. For example, if the first item is dragged to the fifth position, the event will emit{from: 0, to: 4}
. Note that the index starts at zero.A function should be called when the event is emitted that handles the reordering of the items. See [usage](#usage) below for some examples.
<ion-list><ion-list-header>Header</ion-list-header><ion-item-group reorder="true" (ionItemReorder)="reorderItems($event)"><ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item></ion-item-group></ion-list>class MyComponent {items = [];constructor() {for (let x = 0; x < 5; x++) {this.items.push(x);}}reorderItems(indexes) {let element = this.items[indexes.from];this.items.splice(indexes.from, 1);this.items.splice(indexes.to, 0, element);}}Ionic also provides a helper function called
reorderArray
to reorder the array of items. This can be used instead:import { reorderArray } from 'ionic-angular';class MyComponent {items = [];constructor() {for (let x = 0; x < 5; x++) {this.items.push(x);}}reorderItems(indexes) {this.items = reorderArray(this.items, indexes);}}Alternatevely you can execute helper function inside template:
<ion-list><ion-list-header>Header</ion-list-header><ion-item-group reorder="true" (ionItemReorder)="$event.applyTo(items)"><ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item></ion-item-group></ion-list>/docs/demos/src/item-reorder/
See Also
constructor
constructor( _plt: Platform, _dom: DomController, elementRef: ElementRef, _rendered: Renderer, _zone: NgZone, _content: Content);
property ionItemReorder
ionItemReorder: EventEmitter<ReorderIndexes>;
{object} Emitted when the item is reordered. Emits an object with
from
andto
properties.
property reorder
reorder: boolean;
property side
side: 'start' | 'end';
{string} Which side of the view the ion-reorder should be placed. Default
"end"
.
method getNativeElement
getNativeElement: () => HTMLElement;
method ngOnDestroy
ngOnDestroy: () => void;
method setElementClass
setElementClass: (classname: string, add: boolean) => void;
class ItemSliding
class ItemSliding {}
ItemSliding A sliding item is a list item that can be swiped to reveal buttons. It requires an [Item](../Item) component as a child and a [List](../../list/List) component as a parent. All buttons to reveal can be placed in the
<ion-item-options>
element.<ion-list><ion-item-sliding #item><ion-item>Item</ion-item><ion-item-options side="left"><button ion-button (click)="favorite(item)">Favorite</button><button ion-button color="danger" (click)="share(item)">Share</button></ion-item-options><ion-item-options side="right"><button ion-button (click)="unread(item)">Unread</button></ion-item-options></ion-item-sliding></ion-list>### Swipe Direction By default, the buttons are revealed when the sliding item is swiped from right to left, so the buttons are placed in the right side. But it's also possible to reveal them in the right side (sliding from left to right) by setting the
side
attribute on theion-item-options
element. Up to 2ion-item-options
can used at the same time in order to reveal two different sets of buttons depending the swipping direction.<ion-item-options side="right"><button ion-button (click)="archive(item)"><ion-icon name="archive"></ion-icon>Archive</button></ion-item-options><ion-item-options side="left"><button ion-button (click)="archive(item)"><ion-icon name="archive"></ion-icon>Archive</button></ion-item-options>### Listening for events (ionDrag) and (ionSwipe) It's possible to know the current relative position of the sliding item by subscribing to the (ionDrag)` event.
<ion-item-sliding (ionDrag)="logDrag($event)"><ion-item>Item</ion-item><ion-item-options><button ion-button>Favorite</button></ion-item-options></ion-item-sliding>### Button Layout If an icon is placed with text in the option button, by default it will display the icon on top of the text. This can be changed to display the icon to the left of the text by setting
icon-start
as an attribute on the<ion-item-options>
element.<ion-item-options icon-start><button ion-button (click)="archive(item)"><ion-icon name="archive"></ion-icon>Archive</button></ion-item-options>### Expandable Options
Options can be expanded to take up the full width of the item if you swipe past a certain point. This can be combined with the
ionSwipe
event to call methods on the class.<ion-item-sliding><ion-item>Item</ion-item><ion-item-options (ionSwipe)="delete(item)"><button ion-button expandable (click)="delete(item)">Delete</button></ion-item-options></ion-item-sliding>We can call
delete
by either clicking the button, or by doing a full swipe on the item./docs/demos/src/item-sliding/
See Also
constructor
constructor( list: List, _plt: Platform, _renderer: Renderer, _elementRef: ElementRef, _zone: NgZone);
property ionDrag
ionDrag: EventEmitter<ItemSliding>;
{event} Emitted when the sliding position changes. It reports the relative position.
ondrag(item) {let percent = item.getSlidingPercent();if (percent > 0) {// positiveconsole.log('right side');} else {// negativeconsole.log('left side');}if (Math.abs(percent) > 1) {console.log('overscroll');}}
property item
item: Item;
method close
close: () => void;
Close the sliding item. Items can also be closed from the [List](../../list/List).
The sliding item can be closed by grabbing a reference to
ItemSliding
. In the below example, the template reference variableslidingItem
is placed on the element and passed to theshare
method.<ion-list><ion-item-sliding #slidingItem><ion-item>Item</ion-item><ion-item-options><button ion-button (click)="share(slidingItem)">Share</button></ion-item-options></ion-item-sliding></ion-list>import { Component } from '@angular/core';import { ItemSliding } from 'ionic-angular';@Component({...})export class MyClass {constructor() { }share(slidingItem: ItemSliding) {slidingItem.close();}}
method endSliding
endSliding: (velocity: number) => number;
method getOpenAmount
getOpenAmount: () => number;
method getSlidingPercent
getSlidingPercent: () => number;
method moveSliding
moveSliding: (x: number) => number;
method setElementClass
setElementClass: (cssClass: string, shouldAdd: boolean) => void;
method startSliding
startSliding: (startX: number) => void;
class Keyboard
class Keyboard {}
Keyboard The
Keyboard
class allows you to work with the keyboard events provided by the Ionic keyboard plugin.export class MyClass {constructor(public keyboard: Keyboard) { }}
constructor
constructor(config: Config, _plt: Platform, _zone: NgZone, _dom: DomController);
property didHide
didHide: EventEmitter<void>;
property didShow
didShow: EventEmitter<number>;
property eventsAvailable
eventsAvailable: boolean;
property willHide
willHide: EventEmitter<void>;
property willShow
willShow: EventEmitter<number>;
method close
close: () => void;
Programmatically close the keyboard.
method focusOutline
focusOutline: (setting: any) => void;
method hasFocusedTextInput
hasFocusedTextInput: () => boolean;
method hideFormAccessoryBar
hideFormAccessoryBar: (hidden: boolean) => void;
Set to true to hide the additional toolbar that is on top of the keyboard. This toolbar features the Prev, Next, and Done buttons.
Parameter hidden
method isOpen
isOpen: () => boolean;
Check to see if the keyboard is open or not.
export class MyClass {constructor(public keyboard: Keyboard) {}keyboardCheck() {console.log('The keyboard is open:', this.keyboard.isOpen());}}{boolean} returns a true or false value if the keyboard is open or not.
method onClose
onClose: ( callback: Function, pollingInternval?: number, pollingChecksMax?: number) => Promise<any>;
When the keyboard is closed, call any methods you want.
export class MyClass {constructor(public keyboard: Keyboard) {this.keyboard.onClose(this.closeCallback);}closeCallback() {// call what ever functionality you want on keyboard closeconsole.log('Closing time');}}Parameter callback
method you want to call when the keyboard has been closed. {function} returns a callback that gets fired when the keyboard is closed.
class Label
class Label extends Ion {}
Label Labels are placed inside of an
ion-item
element and can be used to describe anion-input
,ion-toggle
,ion-checkbox
, and more.[fixed] - A persistent label that sits next the input. [floating] - A label that will float above the input if the input is empty or loses focus. [stacked] - A stacked label will always appear on top of the input.
<ion-item><ion-label>Username</ion-label><ion-input></ion-input></ion-item><ion-item><ion-label fixed>Website</ion-label><ion-input type="url"></ion-input></ion-item><ion-item><ion-label floating>Email</ion-label><ion-input type="email"></ion-input></ion-item><ion-item><ion-label stacked>Phone</ion-label><ion-input type="tel"></ion-input></ion-item><ion-item><ion-label>Toggle</ion-label><ion-toggle></ion-toggle></ion-item><ion-item><ion-label>Checkbox</ion-label><ion-checkbox></ion-checkbox></ion-item>/docs/demos/src/label/
See Also
constructor
constructor( config: Config, elementRef: ElementRef, renderer: Renderer, isFloating: string, isStacked: string, isFixed: string, isInset: string);
property id
id: string;
property text
readonly text: string;
property type
type: string;
class List
class List extends Ion {}
The List is a widely used interface element in almost any mobile app, and can include content ranging from basic text all the way to buttons, toggles, icons, and thumbnails.
Both the list, which contains items, and the list items themselves can be any HTML element.
Using the List and Item components make it easy to support various interaction modes such as swipe to edit, drag to reorder, and removing items.
/docs/demos/src/list/
See Also
Enable the sliding items.
import { Component, ViewChild } from '@angular/core';import { List } from 'ionic-angular';@Component({...})export class MyClass {@ViewChild(List) list: List;constructor() { }stopSliding() {this.list.enableSlidingItems(false);}}
constructor
constructor( config: Config, elementRef: ElementRef, renderer: Renderer, _plt: Platform, _gestureCtrl: GestureController, _domCtrl: DomController);
property sliding
sliding: boolean;
{boolean} If true, the sliding items will be enabled.
method closeSlidingItems
closeSlidingItems: () => void;
Close any sliding items that are open.
method containsSlidingItem
containsSlidingItem: (contains: boolean) => void;
method destroy
destroy: () => void;
class ListHeader
class ListHeader extends Ion {}
constructor
constructor( config: Config, renderer: Renderer, elementRef: ElementRef, _id: string);
property id
id: string;
class Loading
class Loading extends ViewController {}
constructor
constructor(app: App, opts: LoadingOptions, config: Config);
method dismissAll
dismissAll: () => void;
Dismiss all loading components which have been presented.
method getTransitionName
getTransitionName: (direction: string) => string;
method present
present: (navOptions?: NavOptions) => Promise<any>;
Present the loading instance.
Parameter navOptions
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method setContent
setContent: (content: string) => Loading;
Parameter content
sets the html content for the loading indicator.
method setCssClass
setCssClass: (cssClass: string) => Loading;
Parameter cssClass
sets additional classes for custom styles, separated by spaces.
method setDuration
setDuration: (dur: number) => Loading;
Parameter dur
how many milliseconds to wait before hiding the indicator.
method setShowBackdrop
setShowBackdrop: (showBackdrop: boolean) => Loading;
Parameter showBackdrop
sets whether to show the backdrop.
method setSpinner
setSpinner: (spinner: string) => Loading;
Parameter spinner
sets the name of the SVG spinner for the loading indicator.
class LoadingCmp
class LoadingCmp {}
constructor
constructor( _viewCtrl: ViewController, _config: Config, _elementRef: ElementRef, gestureCtrl: GestureController, params: NavParams, renderer: Renderer);
property d
d: LoadingOptions;
property durationTimeout
durationTimeout: any;
property gestureBlocker
gestureBlocker: BlockerDelegate;
property id
id: number;
property showSpinner
showSpinner: boolean;
method bdClick
bdClick: () => void;
method dismiss
dismiss: (role: string) => Promise<any>;
method ionViewDidEnter
ionViewDidEnter: () => void;
method ionViewDidLeave
ionViewDidLeave: () => void;
method ionViewWillEnter
ionViewWillEnter: () => void;
method keyUp
keyUp: (ev: KeyboardEvent) => void;
method ngOnDestroy
ngOnDestroy: () => void;
method ngOnInit
ngOnInit: () => void;
class LoadingController
class LoadingController {}
LoadingController An overlay that can be used to indicate activity while blocking user interaction. The loading indicator appears on top of the app's content, and can be dismissed by the app to resume user interaction with the app. It includes an optional backdrop, which can be disabled by setting
showBackdrop: false
upon creation.### Creating You can pass all of the loading options in the first argument of the create method:
create(opts)
. The spinner name should be passed in thespinner
property, and any optional HTML can be passed in thecontent
property. If you do not pass a value tospinner
the loading indicator will use the spinner specified by the mode. To set the spinner name across the app, set the value ofloadingSpinner
in your app's config. To hide the spinner, setloadingSpinner: 'hide'
in the app's config or passspinner: 'hide'
in the loading options. See the [create](#create) method below for all available options.### Dismissing The loading indicator can be dismissed automatically after a specific amount of time by passing the number of milliseconds to display it in the
duration
of the loading options. By default the loading indicator will show even during page changes, but this can be disabled by settingdismissOnPageChange
totrue
. To dismiss the loading indicator after creation, call thedismiss()
method on the Loading instance. TheonDidDismiss
function can be called to perform an action after the loading indicator is dismissed.>Note that after the component is dismissed, it will not be usable anymore and another one must be created. This can be avoided by wrapping the creation and presentation of the component in a reusable function as shown in the
usage
section below.### Limitations The element is styled to appear on top of other content by setting its
z-index
property. You must ensure no element has a stacking context with a higherz-index
than this element.import { LoadingController } from 'ionic-angular';constructor(public loadingCtrl: LoadingController) { }presentLoadingDefault() {const loading = this.loadingCtrl.create({content: 'Please wait...'});loading.present();setTimeout(() => {loading.dismiss();}, 5000);}presentLoadingCustom() {const loading = this.loadingCtrl.create({spinner: 'hide',content: `<div class="custom-spinner-container"><div class="custom-spinner-box"></div></div>`,duration: 5000});loading.onDidDismiss(() => {console.log('Dismissed loading');});loading.present();}presentLoadingText() {const loading = this.loadingCtrl.create({spinner: 'hide',content: 'Loading Please Wait...'});loading.present();setTimeout(() => {this.nav.push(Page2);}, 1000);setTimeout(() => {loading.dismiss();}, 5000);}Loading options
| Option | Type | Description | |-----------------------|------------|------------------------------------------------------------------------------------------------------------------| | spinner |
string
| The name of the SVG spinner for the loading indicator. | | content |string
| The html content for the loading indicator. | | cssClass |string
| Additional classes for custom styles, separated by spaces. | | showBackdrop |boolean
| Whether to show the backdrop. Default true. | | enableBackdropDismiss |boolean
| Whether the loading indicator should be dismissed by tapping the backdrop. Default false. | | dismissOnPageChange |boolean
| Whether to dismiss the indicator when navigating to a new page. Default false. | | duration |number
| How many milliseconds to wait before hiding the indicator. By default, it will show untildismiss()
is called. |/docs/demos/src/loading/
See Also
constructor
constructor(_app: App, config: Config);
property config
config: Config;
method create
create: (opts?: LoadingOptions) => Loading;
Create a loading indicator. See below for options.
Parameter opts
Loading options
Returns
{Loading} Returns a Loading Instance
class Menu
class Menu implements RootNode, MenuInterface, OnInit, OnDestroy {}
Menu The Menu component is a navigation drawer that slides in from the side of the current view. By default, it slides in from the left, but the side can be overridden. The menu will be displayed differently based on the mode, however the display type can be changed to any of the available [menu types](#menu-types). The menu element should be a sibling to the app's content element. There can be any number of menus attached to the content. These can be controlled from the templates, or programmatically using the [MenuController](../../app/MenuController).
<ion-menu [content]="mycontent"><ion-content><ion-list><p>some menu content, could be list items</p></ion-list></ion-content></ion-menu><ion-nav #mycontent [root]="rootPage"></ion-nav>To add a menu to an app, the
<ion-menu>
element should be added as a sibling to theion-nav
it will belong to. A [local variable](https://angular.io/docs/ts/latest/guide/user-input.html#local-variables) should be added to theion-nav
and passed to theion-menu
scontent
property.This tells the menu what it is bound to and what element to watch for gestures. In the below example,
content
is using [property binding](https://angular.io/docs/ts/latest/guide/template-syntax.html#!#property-binding) becausemycontent
is a reference to the<ion-nav>
element, and not a string.### Opening/Closing Menus
There are several ways to open or close a menu. The menu can be **toggled** open or closed from the template using the [MenuToggle](../MenuToggle) directive. It can also be **closed** from the template using the [MenuClose](../MenuClose) directive. To display a menu programmatically, inject the [MenuController](../MenuController) provider and call any of the
MenuController
methods.### Menu Types
The menu supports several display types:
overlay
,reveal
andpush
. By default, it will use the correct type based on the mode, but this can be changed. The default type for both Material Design and Windows mode isoverlay
, andreveal
is the default type for iOS mode. The menu type can be changed in the app's [config](../../config/Config) via themenuType
property, or passed in thetype
property on the<ion-menu>
element. See [usage](#usage) below for examples of changing the menu type.### Navigation Bar Behavior
If a [MenuToggle](../MenuToggle) button is added to the [Navbar](../../navbar/Navbar) of a page, the button will only appear when the page it's in is currently a root page. The root page is the initial page loaded in the app, or a page that has been set as the root using the [setRoot](../../nav/NavController/#setRoot) method on the [NavController](../../nav/NavController).
For example, say the application has two pages,
Page1
andPage2
, and both have aMenuToggle
button in their navigation bars. Assume the initial page loaded into the app isPage1
, making it the root page.Page1
will display theMenuToggle
button, but oncePage2
is pushed onto the navigation stack, theMenuToggle
will not be displayed.### Persistent Menus
Persistent menus display the [MenuToggle](../MenuToggle) button in the [Navbar](../../navbar/Navbar) on all pages in the navigation stack. To make a menu persistent set
persistent
totrue
on the<ion-menu>
element. Note that this will only affect theMenuToggle
button in theNavbar
attached to theMenu
withpersistent
set to true, any otherMenuToggle
buttons will not be affected. ### Menu SideBy default, menus slide in from the left, but this can be overridden by passing
right
to theside
property:<ion-menu side="right" [content]="mycontent">...</ion-menu>### Menu Type
The menu type can be changed by passing the value to
type
on the<ion-menu>
:<ion-menu type="overlay" [content]="mycontent">...</ion-menu>It can also be set in the app's config. The below will set the menu type to
push
for all modes, and then set the type tooverlay
for theios
mode.// in NgModulesimports: [IonicModule.forRoot(MyApp,{menuType: 'push',platforms: {ios: {menuType: 'overlay',}}})],### Displaying the Menu
To toggle a menu from the template, add a button with the
menuToggle
directive anywhere in the page's template:<button ion-button menuToggle>Toggle Menu</button>To close a menu, add the
menuClose
button. It can be added anywhere in the content, or even the menu itself. Below it is added to the menu's content:<ion-menu [content]="mycontent"><ion-content><ion-list><ion-item menuClose detail-none>Close Menu</ion-item></ion-list></ion-content></ion-menu>See the [MenuToggle](../MenuToggle) and [MenuClose](../MenuClose) docs for more information on these directives.
The menu can also be controlled from the Page by using the
MenuController
. Inject theMenuController
provider into the page and then call any of its methods. In the below example, theopenMenu
method will open the menu when it is called.import { Component } from '@angular/core';import { MenuController } from 'ionic-angular';@Component({...})export class MyPage {constructor(public menuCtrl: MenuController) {}openMenu() {this.menuCtrl.open();}}See the [MenuController](../../app/MenuController) API docs for all of the methods and usage information.
/docs/demos/src/menu/
See Also
constructor
constructor( _menuCtrl: MenuController, _elementRef: ElementRef, _config: Config, _plt: Platform, _renderer: Renderer, _keyboard: Keyboard, _gestureCtrl: GestureController, _domCtrl: DomController, _app: App);
property backdrop
backdrop: Backdrop;
property content
content: any;
{any} A reference to the content element the menu should use.
property enabled
enabled: boolean;
{boolean} If true, the menu is enabled. Default
true
.
property id
id: string;
{string} An id for the menu.
property ionClose
ionClose: EventEmitter<boolean>;
{event} Emitted when the menu has been closed.
property ionDrag
ionDrag: EventEmitter<number>;
{event} Emitted when the menu is being dragged open.
property ionOpen
ionOpen: EventEmitter<boolean>;
{event} Emitted when the menu has been opened.
property isOpen
isOpen: boolean;
property isRightSide
isRightSide: boolean;
property maxEdgeStart
maxEdgeStart: number;
property menuContent
menuContent: Content;
property menuNav
menuNav: Nav;
property persistent
persistent: boolean;
{boolean} If true, the menu will persist on child pages.
property side
side: Side;
{string} Which side of the view the menu should be placed. Default
"left"
.
property swipeEnabled
swipeEnabled: boolean;
{boolean} If true, swiping the menu is enabled. Default
true
.
property type
type: string;
{string} The display type of the menu. Default varies based on the mode, see the
menuType
in the [config](../../config/Config). Available options:"overlay"
,"reveal"
,"push"
.
method canSwipe
canSwipe: () => boolean;
method close
close: () => Promise<boolean>;
method enable
enable: (shouldEnable: boolean) => Menu;
method getBackdropElement
getBackdropElement: () => HTMLElement;
method getContentElement
getContentElement: () => HTMLElement;
method getElementRef
getElementRef: () => ElementRef;
method getMenuController
getMenuController: () => MenuController;
method getMenuElement
getMenuElement: () => HTMLElement;
method getNativeElement
getNativeElement: () => HTMLElement;
method isAnimating
isAnimating: () => boolean;
method ngOnDestroy
ngOnDestroy: () => void;
method ngOnInit
ngOnInit: () => void;
method onBackdropClick
onBackdropClick: (ev: UIEvent) => void;
method open
open: () => Promise<boolean>;
method resize
resize: () => void;
method setElementAttribute
setElementAttribute: (attributeName: string, value: string) => void;
method setElementClass
setElementClass: (className: string, add: boolean) => void;
method setOpen
setOpen: (shouldOpen: boolean, animated?: boolean) => Promise<boolean>;
method swipeEnable
swipeEnable: (shouldEnable: boolean) => Menu;
method toggle
toggle: () => Promise<boolean>;
method width
width: () => number;
class MenuClose
class MenuClose {}
MenuClose The
menuClose
directive can be placed on any button to close an open menu.A simple
menuClose
button can be added using the following markup:<button ion-button menuClose>Close Menu</button>To close a certain menu by its id or side, give the
menuClose
directive a value.<button ion-button menuClose="left">Close Left Menu</button>/docs/demos/src/menu/
See Also
constructor
constructor(_menu: MenuController);
property menuClose
menuClose: string;
method close
close: () => void;
class MenuController
class MenuController {}
MenuController The MenuController is a provider which makes it easy to control a [Menu](../../menu/Menu/). Its methods can be used to display the menu, enable the menu, toggle the menu, and more. The controller will grab a reference to the menu by the
side
,id
, or, if neither of these are passed to it, it will grab the first menu it finds.Add a basic menu component to start with. See the [Menu](../../menu/Menu/) API docs for more information on adding menu components.
<ion-menu [content]="mycontent"><ion-content><ion-list>...</ion-list></ion-content></ion-menu><ion-nav #mycontent [root]="rootPage"></ion-nav>To call the controller methods, inject the
MenuController
provider into the page. Then, create some methods for opening, closing, and toggling the menu.import { Component } from '@angular/core';import { MenuController } from 'ionic-angular';@Component({...})export class MyPage {constructor(public menuCtrl: MenuController) {}openMenu() {this.menuCtrl.open();}closeMenu() {this.menuCtrl.close();}toggleMenu() {this.menuCtrl.toggle();}}Since only one menu exists, the
MenuController
will grab the correct menu and call the correct method for each.### Multiple Menus on Different Sides
For applications with both a left and right menu, the desired menu can be grabbed by passing the
side
of the menu. If nothing is passed, it will default to the"left"
menu.<ion-menu side="left" [content]="mycontent">...</ion-menu><ion-menu side="right" [content]="mycontent">...</ion-menu><ion-nav #mycontent [root]="rootPage"></ion-nav>toggleLeftMenu() {this.menuCtrl.toggle();}toggleRightMenu() {this.menuCtrl.toggle('right');}### Multiple Menus on the Same Side
An application can have multiple menus on the same side. In order to determine the menu to control, an
id
should be passed. In the example below, the menu with theauthenticated
id will be enabled, and the menu with theunauthenticated
id will be disabled.<ion-menu id="authenticated" side="left" [content]="mycontent">...</ion-menu><ion-menu id="unauthenticated" side="left" [content]="mycontent">...</ion-menu><ion-nav #mycontent [root]="rootPage"></ion-nav>enableAuthenticatedMenu() {this.menuCtrl.enable(true, 'authenticated');this.menuCtrl.enable(false, 'unauthenticated');}Note: if an app only has one menu, there is no reason to pass an
id
./docs/demos/src/menu/
See Also
method close
close: (menuId?: string) => Promise<boolean>;
Programatically close the Menu. If no
menuId
is given as the first argument then it'll close any menu which is open. If amenuId
is given then it'll close that exact menu.Parameter menuId
Optionally get the menu by its id, or side. {Promise} returns a promise when the menu is fully closed
method create
static create: (type: string, menuCmp: Menu, plt: Platform) => MenuType;
method enable
enable: (shouldEnable: boolean, menuId?: string) => Menu;
Used to enable or disable a menu. For example, there could be multiple left menus, but only one of them should be able to be opened at the same time. If there are multiple menus on the same side, then enabling one menu will also automatically disable all the others that are on the same side.
Parameter menuId
Optionally get the menu by its id, or side. {Menu} Returns the instance of the menu, which is useful for chaining.
method get
get: (menuId?: string) => Menu;
Used to get a menu instance. If a
menuId
is not provided then it'll return the first menu found. If amenuId
isleft
orright
, then it'll return the enabled menu on that side. Otherwise, if amenuId
is provided, then it'll try to find the menu using the menu'sid
property. If a menu is not found then it'll returnnull
.Parameter menuId
Optionally get the menu by its id, or side. {Menu} Returns the instance of the menu if found, otherwise
null
.
method getMenus
getMenus: () => Array<Menu>;
{Array} Returns an array of all menu instances.
method getOpen
getOpen: () => Menu;
{Menu} Returns the instance of the menu already opened, otherwise
null
.
method isAnimating
isAnimating: () => boolean;
{boolean} if any menu is currently animating
method isEnabled
isEnabled: (menuId?: string) => boolean;
Parameter menuId
Optionally get the menu by its id, or side. {boolean} Returns true if the menu is currently enabled, otherwise false.
method isOpen
isOpen: (menuId?: string) => boolean;
Parameter menuId
Optionally get the menu by its id, or side. {boolean} Returns true if the specified menu is currently open, otherwise false. If the menuId is not specified, it returns true if ANY menu is currenly open.
method open
open: (menuId?: string) => Promise<boolean>;
Programatically open the Menu.
Parameter menuId
Optionally get the menu by its id, or side. {Promise} returns a promise when the menu is fully opened
method registerType
static registerType: ( name: string, cls: new (...args: any[]) => MenuType) => void;
method swipeEnable
swipeEnable: (shouldEnable: boolean, menuId?: string) => Menu;
Used to enable or disable the ability to swipe open the menu.
Parameter shouldEnable
True if it should be swipe-able, false if not.
Parameter menuId
Optionally get the menu by its id, or side. {Menu} Returns the instance of the menu, which is useful for chaining.
method toggle
toggle: (menuId?: string) => Promise<boolean>;
Toggle the menu. If it's closed, it will open, and if opened, it will close.
Parameter menuId
Optionally get the menu by its id, or side. {Promise} returns a promise when the menu has been toggled
class MenuToggle
class MenuToggle {}
MenuToggle The
menuToggle
directive can be placed on any button to toggle a menu open or closed. If it is added to the [NavBar](../../toolbar/Navbar) of a page, the button will only appear when the page it's in is currently a root page. See the [Menu Navigation Bar Behavior](../Menu#navigation-bar-behavior) docs for more information.A simple
menuToggle
button can be added using the following markup:<button ion-button menuToggle>Toggle Menu</button>To toggle a specific menu by its id or side, give the
menuToggle
directive a value.<button ion-button menuToggle="right">Toggle Right Menu</button>If placing the
menuToggle
in a navbar or toolbar, it should be placed as a child of the<ion-navbar>
or<ion-toolbar>
, and not in the<ion-buttons>
element:<ion-header><ion-navbar><ion-buttons start><button ion-button><ion-icon name="contact"></ion-icon></button></ion-buttons><button ion-button menuToggle><ion-icon name="menu"></ion-icon></button><ion-title>Title</ion-title><ion-buttons end><button ion-button (click)="doClick()"><ion-icon name="more"></ion-icon></button></ion-buttons></ion-navbar></ion-header>Similar to
<ion-buttons>
, themenuToggle
can be positioned usingstart
,end
,left
, orright
:<ion-toolbar><button ion-button menuToggle right><ion-icon name="menu"></ion-icon></button><ion-title>Title</ion-title><ion-buttons end><button ion-button (click)="doClick()"><ion-icon name="more"></ion-icon></button></ion-buttons></ion-toolbar>See the [Toolbar API docs](../../toolbar/Toolbar) for more information on the different positions.
/docs/demos/src/menu/
See Also
constructor
constructor( _menu: MenuController, _viewCtrl: ViewController, _button: Button, _navbar: Navbar);
property isHidden
readonly isHidden: boolean;
property menuToggle
menuToggle: string;
method ngAfterContentInit
ngAfterContentInit: () => void;
method toggle
toggle: () => void;
class MenuType
class MenuType implements IMenuType {}
Menu Type Base class which is extended by the various types. Each type will provide their own animations for open and close and registers itself with Menu.
constructor
constructor(plt: Platform);
property ani
ani: Animation;
property isOpening
isOpening: boolean;
method destroy
destroy: () => void;
method setOpen
setOpen: (shouldOpen: boolean, animated: boolean, done: Function) => void;
method setProgessStep
setProgessStep: (stepValue: number) => void;
method setProgressEnd
setProgressEnd: ( shouldComplete: boolean, currentStepValue: number, velocity: number, done: Function) => void;
method setProgressStart
setProgressStart: (isOpen: boolean) => void;
class Modal
class Modal extends OverlayProxy {}
constructor
constructor( app: App, component: any, data: any, opts: ModalOptions, config: Config, deepLinker: DeepLinker);
property isOverlay
isOverlay: boolean;
method getImplementation
getImplementation: () => Overlay;
class ModalCmp
class ModalCmp {}
constructor
constructor( _cfr: ComponentFactoryResolver, _renderer: Renderer, _elementRef: ElementRef, _navParams: NavParams, _viewCtrl: ViewController, gestureCtrl: GestureController, moduleLoader: ModuleLoader);
property moduleLoader
moduleLoader: ModuleLoader;
method ionViewPreLoad
ionViewPreLoad: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
class ModalController
class ModalController {}
ModalController A Modal is a content pane that goes over the user's current page. Usually it is used for making a choice or editing an item. A modal uses the
NavController
to itself in the root nav stack. It is added to the stack similar to how works.When a modal (or any other overlay such as an alert or actionsheet) is "presented" to a nav controller, the overlay is added to the app's root nav. After the modal has been presented, from within the component instance, the modal can later be closed or "dismissed" by using the ViewController's
dismiss
method. Additionally, you can dismiss any overlay by usingpop
on the root nav controller. Modals are not reusable. When a modal is dismissed it is destroyed.Data can be passed to a new modal through
Modal.create()
as the second argument. The data can then be accessed from the opened page by injectingNavParams
. Note that the page, which opened as a modal, has no special "modal" logic within it, but usesNavParams
no differently than a standard page.import { ModalController, NavParams } from 'ionic-angular';@Component(...)class HomePage {constructor(public modalCtrl: ModalController) { }presentProfileModal() {const profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });profileModal.present();}}@Component(...)class Profile {constructor(params: NavParams) {console.log('UserId', params.get('userId'));}}| Option | Type | Description | |-----------------------|------------|------------------------------------------------------------------------------------------------------------------| | showBackdrop |
boolean
| Whether to show the backdrop. Default true. | | enableBackdropDismiss |boolean
| Whether the popover should be dismissed by tapping the backdrop. Default true. | | cssClass |string
| Additional classes for custom styles, separated by spaces. |A modal can also emit data, which is useful when it is used to add or edit data. For example, a profile page could slide up in a modal, and on submit, the submit button could pass the updated profile data, then dismiss the modal.
import { Component } from '@angular/core';import { ModalController, ViewController } from 'ionic-angular';@Component(...)class HomePage {constructor(public modalCtrl: ModalController) {}presentContactModal() {let contactModal = this.modalCtrl.create(ContactUs);contactModal.present();}presentProfileModal() {let profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });// fires after dismiss animation finishesprofileModal.onDidDismiss(data => {console.log(data);});// fires before dismiss animation beginsprofileModal.onWillDismiss(data => {console.log(data);});profileModal.present();}}@Component(...)class Profile {constructor(public viewCtrl: ViewController) {}dismiss() {let data = { 'foo': 'bar' };this.viewCtrl.dismiss(data);}}A common issue is that a developer may try to implement navigation in a modal, but when you try NavController.push(), you will notice that the status bar on iOS gets cut off. The proper way to implement navigation in a modal is to make the modal component a navigation container, and set the root page to the page you want to show in your modal.
@Component({template: '<ion-nav [root]="rootPage" [rootParams]="rootParams"></ion-nav>'})export class MyModalWrapper {rootPage = 'MyModalContentPage'; // This is the page you want your modal to displayrootParams;constructor(navParams: NavParams, private viewCtrl: ViewController) {this.rootParams = Object.assign({}, navParams.data, {viewCtrl: viewCtrl});// This line will send the view controller into your child views, so you can dismiss the modals from there.}}/docs/demos/src/modal/
See Also
constructor
constructor(_app: App, config: Config, deepLinker: DeepLinker);
property config
config: Config;
method create
create: (component: any, data?: any, opts?: ModalOptions) => Modal;
Create a modal to display. See below for options.
Parameter component
The Modal view
Parameter data
Any data to pass to the Modal view
Parameter opts
Modal options
class Nav
class Nav extends NavControllerBase implements AfterViewInit, RootNode, INav {}
Nav
ion-nav
is the declarative component for a [NavController](../../../navigation/NavController/).For more information on using nav controllers like Nav or [Tab](../../Tabs/Tab/), take a look at the [NavController API Docs](../../../navigation/NavController/).
You must set a root page to be loaded initially by any Nav you create, using the 'root' property:
import { Component } from '@angular/core';import { GettingStartedPage } from './getting-started';@Component({template: `<ion-nav [root]="root"></ion-nav>`})class MyApp {root = GettingStartedPage;constructor(){}}/docs/demos/src/navigation/
See Also
constructor
constructor( viewCtrl: ViewController, parent: NavController, app: App, config: Config, plt: Platform, elementRef: ElementRef, zone: NgZone, renderer: Renderer, cfr: ComponentFactoryResolver, gestureCtrl: GestureController, transCtrl: TransitionController, linker: DeepLinker, domCtrl: DomController, errHandler: ErrorHandler);
property name
name: string;
{string} a unique name for the nav element
property root
root: any;
{Page} The Page component to load as the root page within this nav.
property rootParams
rootParams: any;
{object} Any nav-params to pass to the root page of this nav.
method getSecondaryIdentifier
getSecondaryIdentifier: () => string;
method getType
getType: () => string;
method goToRoot
goToRoot: (opts: NavOptions) => Promise<any>;
method initPane
initPane: () => boolean;
method ngAfterViewInit
ngAfterViewInit: () => Promise<any>;
method ngOnDestroy
ngOnDestroy: () => void;
method paneChanged
paneChanged: (isPane: boolean) => void;
class Navbar
class Navbar extends ToolbarBase {}
Navbar Navbar acts as the navigational toolbar, which also comes with a back button. A navbar can contain a
ion-title
, any number of buttons, a segment, or a searchbar. Navbars must be placed within an<ion-header>
in order for them to be placed above the content. It's important to note that navbar's are part of the dynamic navigation stack. If you need a static toolbar, use ion-toolbar.<ion-header><ion-navbar><button ion-button icon-only menuToggle><ion-icon name="menu"></ion-icon></button><ion-title>Page Title</ion-title><ion-buttons end><button ion-button icon-only (click)="openModal()"><ion-icon name="options"></ion-icon></button></ion-buttons></ion-navbar></ion-header>/docs/demos/src/navbar/
See Also
constructor
constructor( _app: App, viewCtrl: ViewController, navCtrl: NavController, config: Config, elementRef: ElementRef, renderer: Renderer);
property hideBackButton
hideBackButton: boolean;
{boolean} If true, the back button will be hidden.
method backButtonClick
backButtonClick: (ev: UIEvent) => void;
method didEnter
didEnter: () => void;
method setBackButtonText
setBackButtonText: (text: string) => void;
Set the text of the Back Button in the Nav Bar. Defaults to "Back".
method setHidden
setHidden: (isHidden: boolean) => void;
class NavController
abstract class NavController implements NavigationContainer {}
NavController
NavController is the base class for navigation controller components like [
Nav
](../../components/nav/Nav/) and [Tab
](../../components/tabs/Tab/). You use navigation controllers to navigate to [pages](#view-creation) in your app. At a basic level, a navigation controller is an array of pages representing a particular history (of a Tab for example). This array can be manipulated to navigate throughout an app by pushing and popping pages or inserting and removing them at arbitrary locations in history.The current page is the last one in the array, or the top of the stack if we think of it that way. [Pushing](#push) a new page onto the top of the navigation stack causes the new page to be animated in, while [popping](#pop) the current page will navigate to the previous page in the stack.
Unless you are using a directive like [NavPush](../../components/nav/NavPush/), or need a specific NavController, most times you will inject and use a reference to the nearest NavController to manipulate the navigation stack.
## Basic usage The simplest way to navigate through an app is to create and initialize a new nav controller using the
<ion-nav>
component.ion-nav
extends theNavController
class.import { Component } from `@angular/core`;import { StartPage } from './start-page';@Component(template: `<ion-nav [root]="rootPage"></ion-nav>`})class MyApp {// set the rootPage to the first page we want displayedpublic rootPage: any = StartPage;constructor(){}}### Injecting NavController Injecting NavController will always get you an instance of the nearest NavController, regardless of whether it is a Tab or a Nav.
Behind the scenes, when Ionic instantiates a new NavController, it creates an injector with NavController bound to that instance (usually either a Nav or Tab) and adds the injector to its own providers. For more information on providers and dependency injection, see [Dependency Injection](https://angular.io/docs/ts/latest/guide/dependency-injection.html).
Instead, you can inject NavController and know that it is the correct navigation controller for most situations (for more advanced situations, see [Menu](../../menu/Menu/) and [Tab](../../tab/Tab/)).
import { NavController } from 'ionic-angular';class MyComponent {constructor(public navCtrl: NavController) {}}### Navigating from the Root component What if you want to control navigation from your root app component? You can't inject
NavController
because any components that are navigation controllers are _children_ of the root component so they aren't available to be injected.By adding a reference variable to the
ion-nav
, you can use@ViewChild
to get an instance of theNav
component, which is a navigation controller (it extendsNavController
):import { Component, ViewChild } from '@angular/core';import { NavController } from 'ionic-angular';@Component({template: '<ion-nav #myNav [root]="rootPage"></ion-nav>'})export class MyApp {@ViewChild('myNav') nav: NavControllerpublic rootPage: any = TabsPage;// Wait for the components in MyApp's template to be initialized// In this case, we are waiting for the Nav with reference variable of "#myNav"ngOnInit() {// Let's navigate from TabsPage to Page1this.nav.push(Page1);}}### Navigating from an Overlay Component What if you wanted to navigate from an overlay component (popover, modal, alert, etc)? In this example, we've displayed a popover in our app. From the popover, we'll get a reference of the root
NavController
in our app, using thegetRootNav()
method.import { Component } from '@angular/core';import { App, ViewController } from 'ionic-angular';@Component({template: `<ion-content><h1>My PopoverPage</h1><button ion-button (click)="pushPage()">Call pushPage</button></ion-content>`})class PopoverPage {constructor(public viewCtrl: ViewControllerpublic appCtrl: App) {}pushPage() {this.viewCtrl.dismiss();this.appCtrl.getRootNav().push(SecondPage);}}## View creation Views are created when they are added to the navigation stack. For methods like [push()](#push), the NavController takes any component class that is decorated with
@Component
as its first argument. The NavController then compiles that component, adds it to the app and animates it into view.By default, pages are cached and left in the DOM if they are navigated away from but still in the navigation stack (the exiting page on a
push()
for example). They are destroyed when removed from the navigation stack (on [pop()](#pop) or [setRoot()](#setRoot)).## Pushing a View To push a new view onto the navigation stack, use the
push
method. If the page has an [<ion-navbar>
](../../components/toolbar/Navbar/), a back button will automatically be added to the pushed view.Data can also be passed to a view by passing an object to the
push
method. The pushed view can then receive the data by accessing it via theNavParams
class.import { Component } from '@angular/core';import { NavController } from 'ionic-angular';import { OtherPage } from './other-page';@Component({template: `<ion-header><ion-navbar><ion-title>Login</ion-title></ion-navbar></ion-header><ion-content><button ion-button (click)="pushPage()">Go to OtherPage</button></ion-content>`})export class StartPage {constructor(public navCtrl: NavController) {}pushPage(){// push another page onto the navigation stack// causing the nav controller to transition to the new page// optional data can also be passed to the pushed page.this.navCtrl.push(OtherPage, {id: "123",name: "Carl"});}}import { NavParams } from 'ionic-angular';@Component({template: `<ion-header><ion-navbar><ion-title>Other Page</ion-title></ion-navbar></ion-header><ion-content>I'm the other page!</ion-content>`})class OtherPage {constructor(private navParams: NavParams) {let id = navParams.get('id');let name = navParams.get('name');}}## Removing a view To remove a view from the stack, use the
pop
method. Popping a view will transition to the previous view.import { Component } from '@angular/core';import { NavController } from 'ionic-angular';@Component({template: `<ion-header><ion-navbar><ion-title>Other Page</ion-title></ion-navbar></ion-header><ion-content>I'm the other page!</ion-content>`})class OtherPage {constructor(public navCtrl: NavController ){}popView(){this.navCtrl.pop();}}## Lifecycle events Lifecycle events are fired during various stages of navigation. They can be defined in any component type which is pushed/popped from a
NavController
.import { Component } from '@angular/core';@Component({template: 'Hello World'})class HelloWorld {ionViewDidLoad() {console.log("I'm alive!");}ionViewWillLeave() {console.log("Looks like I'm about to leave :(");}}| Page Event | Returns | Description | |---------------------|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
ionViewDidLoad
| void | Runs when the page has loaded. This event only happens once per page being created. If a page leaves but is cached, then this event will not fire again on a subsequent viewing. TheionViewDidLoad
event is good place to put your setup code for the page. | |ionViewWillEnter
| void | Runs when the page is about to enter and become the active page. | |ionViewDidEnter
| void | Runs when the page has fully entered and is now the active page. This event will fire, whether it was the first load or a cached page. | |ionViewWillLeave
| void | Runs when the page is about to leave and no longer be the active page. | |ionViewDidLeave
| void | Runs when the page has finished leaving and is no longer the active page. | |ionViewWillUnload
| void | Runs when the page is about to be destroyed and have its elements removed. | |ionViewCanEnter
| boolean/Promise<void> | Runs before the view can enter. This can be used as a sort of "guard" in authenticated views where you need to check permissions before the view can enter | |ionViewCanLeave
| boolean/Promise<void> | Runs before the view can leave. This can be used as a sort of "guard" in authenticated views where you need to check permissions before the view can leave |Those events are only fired on IonicPage, for classic Angular Component, use [Angular Lifecycle Hooks](https://angular.io/guide/lifecycle-hooks).
## Nav Guards
In some cases, a developer should be able to control views leaving and entering. To allow for this, NavController has the
ionViewCanEnter
andionViewCanLeave
methods. Similar to Angular route guards, but are more integrated with NavController. For example, if you wanted to prevent a user from leaving a view:export class MyClass{constructor(public navCtrl: NavController){}pushPage(){this.navCtrl.push(DetailPage);}ionViewCanLeave(): boolean{// here we can either return true or false// depending on if we want to leave this viewif(isValid(randomValue)){return true;} else {return false;}}}We need to make sure that our
navCtrl.push
has a catch in order to catch the and handle the error. If you need to prevent a view from entering, you can do the same thingexport class MyClass{constructor(public navCtrl: NavController){}pushPage(){this.navCtrl.push(DetailPage);}}export class DetailPage(){constructor(public navCtrl: NavController){}ionViewCanEnter(): boolean{// here we can either return true or false// depending on if we want to enter this viewif(isValid(randomValue)){return true;} else {return false;}}}Similar to
ionViewCanLeave
we still need a catch on the originalnavCtrl.push
in order to handle it properly. When handling the back button in theion-navbar
, the catch is already taken care of for you by the framework.## NavOptions
Some methods on
NavController
allow for customizing the current transition. To do this, we can pass an object with the modified properites.| Property | Value | Description | |-----------|-----------|------------------------------------------------------------------------------------------------------------| | animate |
boolean
| Whether or not the transition should animate. | | animation |string
| What kind of animation should be used. | | direction |string
| The conceptual direction the user is navigating. For example, is the user navigatingforward
, orback
? | | duration |number
| The length in milliseconds the animation should take. | | easing |string
| The easing for the animation. |The property 'animation' understands the following values:
md-transition
,ios-transition
andwp-transition
.See Also
property config
config: Config;
property id
id: string;
property name
name: string;
property parent
parent: any;
The parent navigation instance. If this is the root nav, then it'll be
null
. ATab
instance's parent isTabs
, otherwise the parent would be another nav, if it's not already the root nav.
property swipeBackEnabled
swipeBackEnabled: boolean;
{boolean} If true, swipe to go back is enabled.
property viewDidEnter
viewDidEnter: EventEmitter<any>;
Observable to be subscribed to when a component has fully become the active component.
Returns
{Observable} Returns an observable
property viewDidLeave
viewDidLeave: EventEmitter<any>;
Observable to be subscribed to when a component has fully left and is no longer active.
Returns
{Observable} Returns an observable
property viewDidLoad
viewDidLoad: EventEmitter<any>;
Observable to be subscribed to when a component is loaded.
Returns
{Observable} Returns an observable
property viewWillEnter
viewWillEnter: EventEmitter<any>;
Observable to be subscribed to when a component is about to be loaded.
Returns
{Observable} Returns an observable
property viewWillLeave
viewWillLeave: EventEmitter<any>;
Observable to be subscribed to when a component is about to leave, and no longer active.
Returns
{Observable} Returns an observable
property viewWillUnload
viewWillUnload: EventEmitter<any>;
Observable to be subscribed to when a component is about to be unloaded and destroyed.
Returns
{Observable} Returns an observable
method canGoBack
abstract canGoBack: () => boolean;
Returns
true
if there's a valid previous page that we can pop back to. Otherwise returnsfalse
.Returns
{boolean}
method canSwipeBack
abstract canSwipeBack: () => boolean;
If it's possible to use swipe back or not. If it's not possible to go back, or swipe back is not enabled, then this will return
false
. If it is possible to go back, and swipe back is enabled, then this will returntrue
.Returns
{boolean}
method first
abstract first: () => ViewController;
Returns the first view controller in this nav controller's stack.
Returns
{ViewController}
method getActive
abstract getActive: (includeEntering?: boolean) => ViewController;
Returns
{ViewController} Returns the active page's view controller.
method getActiveChildNav
abstract getActiveChildNav: () => any;
Returns the active child navigation.
method getActiveChildNavs
abstract getActiveChildNavs: () => any[];
Returns a list of the active child navigation.
method getAllChildNavs
abstract getAllChildNavs: () => any[];
Returns a list of all child navigation containers
method getByIndex
abstract getByIndex: (index: number) => ViewController;
Parameter index
The index of the page to get.
Returns
{ViewController} Returns the view controller that matches the given index.
method getPrevious
abstract getPrevious: (view?: ViewController) => ViewController;
Returns the view controller which is before the given view controller. If no view controller is passed in, then it'll default to the active view.
Parameter view
Returns
{viewController}
method getSecondaryIdentifier
abstract getSecondaryIdentifier: () => string;
method getType
abstract getType: () => string;
method getViews
abstract getViews: () => Array<ViewController>;
Returns the current stack of views in this nav controller.
Returns
{Array} the stack of view controllers in this nav controller.
method goToRoot
abstract goToRoot: (options: NavOptions) => Promise<any>;
method indexOf
abstract indexOf: (view: ViewController) => number;
Returns the index number of the given view controller.
Parameter view
Returns
{number}
method insert
abstract insert: ( insertIndex: number, page: Page | string, params?: any, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Inserts a component into the nav stack at the specified index. This is useful if you need to add a component at any point in your navigation stack.
Parameter insertIndex
The index where to insert the page.
Parameter page
The component class or deeplink name you want to push onto the navigation stack.
Parameter params
Any NavParams you want to pass along to the next view.
Parameter opts
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method insertPages
abstract insertPages: ( insertIndex: number, insertPages: Array<{ page: Page | string; params?: any }>, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Inserts an array of components into the nav stack at the specified index. The last component in the array will become instantiated as a view, and animate in to become the active view.
Parameter insertIndex
The index where you want to insert the page.
Parameter insertPages
An array of objects, each with a
page
and optionallyparams
property.Parameter opts
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method isActive
abstract isActive: (view: ViewController) => boolean;
Returns if the given view is the active view or not.
Parameter view
Returns
{boolean}
method isTransitioning
abstract isTransitioning: (includeAncestors?: boolean) => boolean;
Returns if the nav controller is actively transitioning or not. {boolean}
method last
abstract last: () => ViewController;
Returns the last page in this nav controller's stack.
Returns
{ViewController}
method length
abstract length: () => number;
Returns the number of views in this nav controller.
Returns
{number} The number of views in this stack, including the current view.
method pop
abstract pop: (opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Call to navigate back from a current component. Similar to
push()
, you can also pass navigation options.Parameter opts
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method popAll
abstract popAll: () => Promise<any[]>;
Pop sequently all the pages in the stack.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method popTo
abstract popTo: ( page: Page | string | ViewController, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Pop to a specific view in the history stack. If an already created instance of the page is not found in the stack, then it'll
setRoot
to the nav stack by removing all current pages and pushing on a new instance of the given page. Note that any params passed to this method are not used when an existing page instance has already been found in the stack. Nav params are only used by this method when a new instance needs to be created.Parameter page
The component class or deeplink name you want to push onto the navigation stack.
Parameter opts
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method popToRoot
abstract popToRoot: (opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Navigate back to the root of the stack, no matter how far back that is.
Parameter opts
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method push
abstract push: ( page: Page | string, params?: any, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Push a new component onto the current navigation stack. Pass any aditional information along as an object. This additional information is accessible through NavParams
Parameter page
The component class or deeplink name you want to push onto the navigation stack.
Parameter params
Any NavParams you want to pass along to the next view.
Parameter opts
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method registerChildNav
abstract registerChildNav: (nav: any) => void;
method remove
abstract remove: ( startIndex: number, removeCount?: number, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Removes a page from the nav stack at the specified index.
Parameter startIndex
The starting index to remove pages from the stack. Default is the index of the last page.
Parameter removeCount
The number of pages to remove, defaults to remove
1
.Parameter opts
Any options you want to use pass to transtion.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method removeView
abstract removeView: ( viewController: ViewController, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Removes the specified view controller from the nav stack.
Parameter viewController
The viewcontroller to remove.
Parameter opts
Any options you want to use pass to transtion.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method resize
abstract resize: () => void;
method setPages
abstract setPages: ( pages: ({ page: Page | string; params?: any } | ViewController)[], opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Set the views of the current navigation stack and navigate to the last view. By default animations are disabled, but they can be enabled by passing options to the navigation controller.You can also pass any navigation params to the individual pages in the array.
Parameter pages
An array of objects, each with a
page
and optionallyparams
property to load in the stack.Parameter opts
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method setRoot
abstract setRoot: ( pageOrViewCtrl: Page | string | ViewController, params?: any, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
Set the root for the current navigation stack.
Parameter pageOrViewCtrl
The name of the component you want to push on the navigation stack.
Parameter params
Any NavParams you want to pass along to the next view.
Parameter opts
Any options you want to use pass to transtion.
Parameter done
Callback function on done.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
class NavControllerBase
class NavControllerBase extends Ion implements NavController {}
This class is for internal use only. It is not exported publicly.
constructor
constructor( parent: any, _app: App, config: Config, plt: Platform, elementRef: ElementRef, _zone: NgZone, renderer: Renderer, _cfr: ComponentFactoryResolver, _gestureCtrl: GestureController, _trnsCtrl: TransitionController, _linker: DeepLinker, _domCtrl: DomController, _errHandler: ErrorHandler);
property config
config: Config;
property id
id: string;
property name
name: string;
property parent
parent: any;
property plt
plt: Platform;
property swipeBackEnabled
swipeBackEnabled: boolean;
property viewDidEnter
viewDidEnter: EventEmitter<any>;
property viewDidLeave
viewDidLeave: EventEmitter<any>;
property viewDidLoad
viewDidLoad: EventEmitter<any>;
property viewWillEnter
viewWillEnter: EventEmitter<any>;
property viewWillLeave
viewWillLeave: EventEmitter<any>;
property viewWillUnload
viewWillUnload: EventEmitter<any>;
method canGoBack
canGoBack: () => boolean;
method canSwipeBack
canSwipeBack: () => boolean;
method destroy
destroy: () => void;
method dismissPageChangeViews
dismissPageChangeViews: () => void;
method first
first: () => ViewController;
method getActive
getActive: () => ViewController;
method getActiveChildNav
getActiveChildNav: () => any;
Returns the active child navigation.
method getActiveChildNavs
getActiveChildNavs: () => any[];
method getAllChildNavs
getAllChildNavs: () => any[];
method getByIndex
getByIndex: (index: number) => ViewController;
method getPrevious
getPrevious: (view?: ViewController) => ViewController;
method getSecondaryIdentifier
getSecondaryIdentifier: () => string;
method getType
getType: () => string;
method getViewById
getViewById: (id: string) => ViewController;
Return a view controller
method getViews
getViews: () => Array<ViewController>;
method goToRoot
goToRoot: (_opts: NavOptions) => Promise<any>;
method hasChildren
hasChildren: () => boolean;
method indexOf
indexOf: (view: ViewController) => number;
method insert
insert: ( insertIndex: number, page: any, params?: any, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method insertPages
insertPages: ( insertIndex: number, insertPages: any[], opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method isActive
isActive: (view: ViewController) => boolean;
method isSwipeBackEnabled
isSwipeBackEnabled: () => boolean;
method isTransitioning
isTransitioning: () => boolean;
method last
last: () => ViewController;
method length
length: () => number;
method pop
pop: (opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method popAll
popAll: () => Promise<any[]>;
method popTo
popTo: ( indexOrViewCtrl: any, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method popToRoot
popToRoot: (opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method push
push: ( page: any, params?: any, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method registerChildNav
registerChildNav: (container: NavigationContainer) => void;
method remove
remove: ( startIndex: number, removeCount?: number, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method removeView
removeView: ( viewController: ViewController, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method resize
resize: () => void;
method setPages
setPages: ( viewControllers: any[], opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method setRoot
setRoot: ( pageOrViewCtrl: any, params?: any, opts?: NavOptions, done?: TransitionDoneFn) => Promise<any>;
method setTransitioning
setTransitioning: (isTransitioning: boolean) => void;
method setViewport
setViewport: (val: ViewContainerRef) => void;
method swipeBackEnd
swipeBackEnd: ( shouldComplete: boolean, currentStepValue: number, velocity: number) => void;
method swipeBackProgress
swipeBackProgress: (stepValue: number) => void;
method swipeBackStart
swipeBackStart: () => void;
method unregisterChildNav
unregisterChildNav: (nav: any) => void;
class NavParams
class NavParams {}
NavParams NavParams are an object that exists on a page and can contain data for that particular view. Similar to how data was pass to a view in V1 with
$stateParams
, NavParams offer a much more flexible option with a simpleget
method.import { NavParams } from 'ionic-angular';export class MyClass{constructor(navParams: NavParams){// userParams is an object we have in our nav-parametersnavParams.get('userParams');}}/docs/demos/src/nav-params/
See Also
constructor
constructor(data?: any);
Parameter data
TODO
property data
data: any;
method get
get: (param: string) => any;
Get the value of a nav-parameter for the current view
import { NavParams } from 'ionic-angular';export class MyClass{constructor(public navParams: NavParams){// userParams is an object we have in our nav-parametersthis.navParams.get('userParams');}}Parameter param
Which param you want to look up
class NavPop
class NavPop {}
NavPop Directive to declaratively pop the current page off from the navigation stack.
<ion-content><button ion-button navPop>Go Back</button></ion-content>Similar to /docs/demos/src/navigation/
See Also
constructor
constructor(_nav: NavController);
method onClick
onClick: () => boolean;
class NavPopAnchor
class NavPopAnchor implements AfterContentInit {}
constructor
constructor(host: NavPop, linker: DeepLinker, viewCtrl: ViewController);
property host
host: NavPop;
property linker
linker: DeepLinker;
property viewCtrl
viewCtrl: ViewController;
method ngAfterContentInit
ngAfterContentInit: () => void;
method updateHref
updateHref: () => void;
class NavPush
class NavPush {}
NavPush Directive to declaratively push a new page to the current nav stack.
<button ion-button [navPush]="pushPage"></button>To specify parameters you can use array syntax or the
navParams
property:<button ion-button [navPush]="pushPage" [navParams]="params">Go</button>Where
pushPage
andparams
are specified in your component, andpushPage
contains a reference to a component you would like to push:import { LoginPage } from './login';@Component({template: `<button ion-button [navPush]="pushPage" [navParams]="params">Go</button>`})class MyPage {pushPage: any;params: Object;constructor(){this.pushPage = LoginPage;this.params = { id: 42 };}}/docs/demos/src/navigation/
See Also
constructor
constructor(_nav: NavController);
property navParams
navParams: { [k: string]: any };
{any} Any NavParams you want to pass along to the next view.
property navPush
navPush: string | Page;
{Page | string} The component class or deeplink name you want to push onto the navigation stack.
method onClick
onClick: () => boolean;
class NavPushAnchor
class NavPushAnchor implements AfterContentInit {}
constructor
constructor(host: NavPush, linker: DeepLinker);
property host
host: NavPush;
property linker
linker: DeepLinker;
method ngAfterContentInit
ngAfterContentInit: () => void;
method updateHref
updateHref: () => void;
class Note
class Note extends Ion {}
Note ionic A note is detailed item in an ion-item. It creates greyed out element that can be on the left or right side of an item.
<ion-content><ion-list><ion-item><ion-note item-start>Left Note</ion-note>My Item<ion-note item-end>Right Note</ion-note></ion-item></ion-list></ion-content>
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class Option
class Option {}
Option
ion-option
is a child component ofion-select
. Similar to the native option element,ion-option
can take a value and a selected property./docs/demos/src/select/
constructor
constructor(_elementRef: ElementRef);
property disabled
disabled: boolean;
{boolean} If true, the user cannot interact with this element.
property ionSelect
ionSelect: EventEmitter<any>;
{any} Event to evaluate when option is selected.
property selected
selected: boolean;
{boolean} If true, the element is selected.
property text
readonly text: any;
property value
value: any;
{any} The value of the option.
class PageTransition
class PageTransition extends Transition {}
property enteringPage
enteringPage: Animation;
method destroy
destroy: () => void;
method init
init: () => void;
class PanGesture
class PanGesture {}
constructor
constructor(plt: Platform, element: HTMLElement, opts?: PanGestureConfig);
property direction
protected direction: string;
property gestute
protected gestute: GestureDelegate;
property isListening
isListening: boolean;
property plt
plt: Platform;
property started
protected started: boolean;
method abort
abort: (ev: any) => void;
method canStart
canStart: (_ev: any) => boolean;
method destroy
destroy: () => void;
method getNativeElement
getNativeElement: () => HTMLElement;
method listen
listen: () => void;
method notCaptured
notCaptured: (_ev: any) => void;
method onDragEnd
onDragEnd: (_ev: any) => void;
method onDragMove
onDragMove: (_ev: any) => void;
method onDragStart
onDragStart: (_ev: any) => void;
method pointerDown
pointerDown: (ev: any) => boolean;
method pointerMove
pointerMove: (ev: any) => void;
method pointerUp
pointerUp: (ev: any) => void;
method tryToCapture
tryToCapture: (ev: any) => boolean;
method unlisten
unlisten: () => void;
class Picker
class Picker extends ViewController {}
constructor
constructor(app: App, opts: PickerOptions, config: Config);
property ionChange
ionChange: EventEmitter<any>;
method addButton
addButton: (button: any) => void;
Parameter button
Picker toolbar button
method addColumn
addColumn: (column: PickerColumn) => void;
Parameter column
Picker toolbar button
method getColumn
getColumn: (name: string) => PickerColumn;
method getColumns
getColumns: () => PickerColumn[];
method getTransitionName
getTransitionName: (direction: string) => any;
method present
present: (navOptions?: NavOptions) => Promise<any>;
Present the picker instance.
Parameter navOptions
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method refresh
refresh: () => void;
method setCssClass
setCssClass: (cssClass: string) => void;
Parameter cssClass
CSS class name to add to the picker's outer wrapper.
class PickerCmp
class PickerCmp {}
constructor
constructor( _viewCtrl: ViewController, _elementRef: ElementRef, config: Config, gestureCtrl: GestureController, params: NavParams, renderer: Renderer);
property d
d: PickerOptions;
property enabled
enabled: boolean;
property id
id: number;
property lastClick
lastClick: number;
property mode
mode: string;
method bdClick
bdClick: () => void;
method btnClick
btnClick: (button: any) => void;
method dismiss
dismiss: (role: string) => Promise<any>;
method getSelected
getSelected: () => any;
method ionViewDidEnter
ionViewDidEnter: () => void;
method ionViewDidLeave
ionViewDidLeave: () => void;
method ionViewDidLoad
ionViewDidLoad: () => void;
method ionViewWillEnter
ionViewWillEnter: () => void;
method ionViewWillLoad
ionViewWillLoad: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method refresh
refresh: () => void;
class PickerColumnCmp
class PickerColumnCmp {}
constructor
constructor( config: Config, _plt: Platform, elementRef: ElementRef, _zone: NgZone, _haptic: Haptic, plt: Platform, domCtrl: DomController);
property bounceFrom
bounceFrom: number;
property col
col: PickerColumn;
property colEle
colEle: ElementRef;
property colHeight
colHeight: number;
property debouncer
debouncer: DomDebouncer;
property decelerateFunc
decelerateFunc: Function;
property events
events: UIEventManager;
property ionChange
ionChange: EventEmitter<any>;
property lastIndex
lastIndex: number;
property lastTempIndex
lastTempIndex: number;
property maxY
maxY: number;
property minY
minY: number;
property optHeight
optHeight: number;
property pos
pos: number[];
property rafId
rafId: number;
property rotateFactor
rotateFactor: number;
property scaleFactor
scaleFactor: number;
property startY
startY: number;
property velocity
velocity: number;
property y
y: number;
method decelerate
decelerate: () => void;
method ngAfterViewInit
ngAfterViewInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method optClick
optClick: (ev: UIEvent, index: number) => void;
method pointerEnd
pointerEnd: (ev: UIEvent) => void;
method pointerMove
pointerMove: (ev: UIEvent) => void;
method pointerStart
pointerStart: (ev: UIEvent) => boolean;
method refresh
refresh: () => void;
method setSelected
setSelected: (selectedIndex: number, duration: number) => void;
method update
update: ( y: number, duration: number, saveY: boolean, emitChange: boolean) => void;
class PickerController
class PickerController {}
PickerController
constructor
constructor(_app: App, config: Config);
property config
config: Config;
method create
create: (opts?: PickerOptions) => Picker;
Open a picker.
class Platform
class Platform {}
Platform The Platform service can be used to get information about your current device. You can get all of the platforms associated with the device using the [platforms](#platforms) method, including whether the app is being viewed from a tablet, if it's on a mobile device or browser, and the exact platform (iOS, Android, etc). You can also get the orientation of the device, if it uses right-to-left language direction, and much much more. With this information you can completely customize your app to fit any device.
import { Platform } from 'ionic-angular';@Component({...})export MyPage {constructor(public platform: Platform) {}}/docs/demos/src/platform/
constructor
constructor();
property backButton
backButton: EventEmitter<Event>;
property isRTL
isRTL: boolean;
Returns if this app is using right-to-left language direction or not. We recommend the app's
index.html
file already has the correctdir
attribute value set, such as<html dir="ltr">
or<html dir="rtl">
. [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)Returns
{boolean}
property pause
pause: EventEmitter<Event>;
The pause event emits when the native platform puts the application into the background, typically when the user switches to a different application. This event would emit when a Cordova app is put into the background, however, it would not fire on a standard web browser.
property resize
resize: EventEmitter<Event>;
The resize event emits when the browser window has changed dimensions. This could be from a browser window being physically resized, or from a device changing orientation.
property resume
resume: EventEmitter<Event>;
The resume event emits when the native platform pulls the application out from the background. This event would emit when a Cordova app comes out from the background, however, it would not fire on a standard web browser.
property zone
zone: NgZone;
method cancelRaf
cancelRaf: (rafId: number) => any;
method cancelTimeout
cancelTimeout: (timeoutId: number) => void;
This setTimeout will NOT be wrapped by zone.
method dir
dir: () => DocumentDirection;
Returns app's language direction. We recommend the app's
index.html
file already has the correctdir
attribute value set, such as<html dir="ltr">
or<html dir="rtl">
. [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)Returns
{DocumentDirection}
method doc
doc: () => HTMLDocument;
method exitApp
exitApp: () => void;
method focusOutActiveElement
focusOutActiveElement: () => void;
method getActiveElement
getActiveElement: () => Element;
method getElementBoundingClientRect
getElementBoundingClientRect: (ele: HTMLElement) => ClientRect;
method getElementComputedStyle
getElementComputedStyle: ( ele: HTMLElement, pseudoEle?: string) => CSSStyleDeclaration;
method getElementFromPoint
getElementFromPoint: (x: number, y: number) => HTMLElement;
method getPlatformConfig
getPlatformConfig: (platformName: string) => PlatformConfig;
method getQueryParam
getQueryParam: (key: string) => any;
Get the query string parameter
method hasFocus
hasFocus: (ele: HTMLElement) => boolean;
method hasFocusedTextInput
hasFocusedTextInput: () => boolean;
method height
height: () => number;
Gets the height of the platform's viewport using
window.innerHeight
. Using this method is preferred since the dimension is a cached value, which reduces the chance of multiple and expensive DOM reads.
method init
init: () => void;
method is
is: (platformName: string) => boolean;
Parameter platformName
Returns
{boolean} returns true/false based on platform. Depending on the platform the user is on,
is(platformName)
will returntrue
orfalse
. Note that the same app can returntrue
for more than one platform name. For example, an app running from an iPad would returntrue
for the platform names:mobile
,ios
,ipad
, andtablet
. Additionally, if the app was running from Cordova thencordova
would be true, and if it was running from a web browser on the iPad thenmobileweb
would betrue
.import { Platform } from 'ionic-angular';@Component({...})export MyPage {constructor(public platform: Platform) {if (this.platform.is('ios')) {// This will only print when on iOSconsole.log('I am an iOS device!');}}}| Platform Name | Description | |-----------------|------------------------------------| | android | on a device running Android. | | cordova | on a device running Cordova. | | core | on a desktop device. | | ios | on a device running iOS. | | ipad | on an iPad device. | | iphone | on an iPhone device. | | mobile | on a mobile device. | | mobileweb | in a browser on a mobile device. | | phablet | on a phablet device. | | tablet | on a tablet device. | | windows | on a device running Windows. | | electron | in Electron on a desktop device. |
method isActiveElement
isActiveElement: (ele: HTMLElement) => boolean;
method isLandscape
isLandscape: () => boolean;
Returns
true
if the app is in landscape mode.
method isPlatformMatch
isPlatformMatch: ( queryStringName: string, userAgentAtLeastHas?: string[], userAgentMustNotHave?: string[]) => boolean;
method isPortrait
isPortrait: () => boolean;
Returns
true
if the app is in portait mode.
method lang
lang: () => string;
Returns app's language and optional country code. We recommend the app's
index.html
file already has the correctlang
attribute value set, such as<html lang="en">
. [W3C: Declaring language in HTML](http://www.w3.org/International/questions/qa-html-language-declarations)Returns
{string}
method matchUserAgentVersion
matchUserAgentVersion: (userAgentExpression: RegExp) => any;
method navigatorPlatform
navigatorPlatform: () => string;
method platforms
platforms: () => Array<string>;
Returns
{array} the array of platforms Depending on what device you are on,
platforms
can return multiple values. Each possible value is a hierarchy of platforms. For example, on an iPhone, it would returnmobile
,ios
, andiphone
.import { Platform } from 'ionic-angular';@Component({...})export MyPage {constructor(public platform: Platform) {// This will print an array of the current platformsconsole.log(this.platform.platforms());}}
method prepareReady
prepareReady: () => void;
This is the default prepareReady if it's not replaced by an engine, such as Cordova or Electron. If there was no custom prepareReady method from an engine then it uses the method below, which triggers the platform ready on the DOM ready event, and the default resolved value is
dom
.
method raf
raf: (callback: Function | ((timeStamp?: number) => void)) => number;
This requestAnimationFrame will NOT be wrapped by zone.
method ready
ready: () => Promise<string>;
Returns a promise when the platform is ready and native functionality can be called. If the app is running from within a web browser, then the promise will resolve when the DOM is ready. When the app is running from an application engine such as Cordova, then the promise will resolve when Cordova triggers the
deviceready
event.The resolved value is the
readySource
, which states which platform ready was used. For example, when Cordova is ready, the resolved ready source iscordova
. The default ready source value will bedom
. ThereadySource
is useful if different logic should run depending on the platform the app is running from. For example, only Cordova can execute the status bar plugin, so the web should not run status bar plugin logic.import { Component } from '@angular/core';import { Platform } from 'ionic-angular';@Component({...})export MyApp {constructor(public platform: Platform) {this.platform.ready().then((readySource) => {console.log('Platform ready from', readySource);// Platform now ready, execute any required native code});}}Returns
{promise}
method registerBackButtonAction
registerBackButtonAction: (fn: Function, priority?: number) => Function;
The back button event is triggered when the user presses the native platform's back button, also referred to as the "hardware" back button. This event is only used within Cordova apps running on Android and Windows platforms. This event is not fired on iOS since iOS doesn't come with a hardware back button in the same sense an Android or Windows device does.
Registering a hardware back button action and setting a priority allows apps to control which action should be called when the hardware back button is pressed. This method decides which of the registered back button actions has the highest priority and should be called.
Parameter fn
Called when the back button is pressed, if this registered action has the highest priority.
Parameter priority
Set the priority for this action. Only the highest priority will execute. Defaults to
0
.Returns
{Function} A function that, when called, will unregister the back button action.
method registerListener
registerListener: ( ele: any, eventName: string, callback: (ev?: UIEvent) => void, opts: EventListenerOptions, unregisterListenersCollection?: Function[]) => Function;
Built to use modern event listener options, like "passive". If options are not supported, then just return a boolean which represents "capture". Returns a method to remove the listener.
method registry
registry: () => { [name: string]: PlatformConfig };
method runBackButtonAction
runBackButtonAction: () => void;
method setCssProps
setCssProps: (docElement: HTMLElement) => void;
method setDefault
setDefault: (platformName: string) => void;
method setDir
setDir: (dir: DocumentDirection, updateDocument: boolean) => void;
Set the app's language direction, which will update the
dir
attribute on the app's root<html>
element. We recommend the app'sindex.html
file already has the correctdir
attribute value set, such as<html dir="ltr">
or<html dir="rtl">
. This method is useful if the direction needs to be dynamically changed per user/session. [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)Parameter dir
Examples:
rtl
,ltr
Parameter updateDocument
method setDocument
setDocument: (doc: HTMLDocument) => void;
method setLang
setLang: (language: string, updateDocument: boolean) => void;
Set the app's language and optionally the country code, which will update the
lang
attribute on the app's root<html>
element. We recommend the app'sindex.html
file already has the correctlang
attribute value set, such as<html lang="en">
. This method is useful if the language needs to be dynamically changed per user/session. [W3C: Declaring language in HTML](http://www.w3.org/International/questions/qa-html-language-declarations)Parameter language
Examples:
en-US
,en-GB
,ar
,de
,zh
,es-MX
Parameter updateDocument
Specifies whether the
lang
attribute of<html>
should be updated
method setNavigatorPlatform
setNavigatorPlatform: (navigatorPlt: string) => void;
method setPlatformConfigs
setPlatformConfigs: (platformConfigs: { [key: string]: PlatformConfig }) => void;
method setQueryParams
setQueryParams: (url: string) => void;
method setUserAgent
setUserAgent: (userAgent: string) => void;
method setWindow
setWindow: (win: Window) => void;
method setZone
setZone: (zone: NgZone) => void;
method testNavigatorPlatform
testNavigatorPlatform: (navigatorPlatformExpression: string) => boolean;
method testQuery
testQuery: (queryValue: string, queryTestValue: string) => boolean;
method testUserAgent
testUserAgent: (expression: string) => boolean;
method timeout
timeout: (callback: Function, timeout?: number) => number;
This setTimeout will NOT be wrapped by zone.
method transitionEnd
transitionEnd: ( el: HTMLElement, callback: (ev?: TransitionEvent) => void, zone?: boolean) => () => void;
method triggerReady
triggerReady: (readySource: string) => void;
This should be triggered by the engine when the platform is ready. If there was no custom prepareReady method from the engine, such as Cordova or Electron, then it uses the default DOM ready.
method url
url: () => string;
Get the current url.
method userAgent
userAgent: () => string;
method version
version: () => PlatformVersion;
method versions
versions: () => { [name: string]: PlatformVersion };
Returns an object containing version information about all of the platforms.
import { Platform } from 'ionic-angular';@Component({...})export MyPage {constructor(public platform: Platform) {// This will print an object containing// all of the platforms and their versionsconsole.log(platform.versions());}}Returns
{object} An object containing all of the platforms and their versions.
method width
width: () => number;
Gets the width of the platform's viewport using
window.innerWidth
. Using this method is preferred since the dimension is a cached value, which reduces the chance of multiple and expensive DOM reads.
method win
win: () => Window;
method windowLoad
windowLoad: (callback: Function) => void;
class Popover
class Popover extends OverlayProxy {}
constructor
constructor( app: App, component: any, data: any, opts: PopoverOptions, config: Config, deepLinker: DeepLinker);
property isOverlay
isOverlay: boolean;
method getImplementation
getImplementation: () => Overlay;
class PopoverCmp
class PopoverCmp {}
constructor
constructor( _cfr: ComponentFactoryResolver, _elementRef: ElementRef, _renderer: Renderer, _config: Config, _navParams: NavParams, _viewCtrl: ViewController, gestureCtrl: GestureController, moduleLoader: ModuleLoader);
property d
d: { cssClass?: string; showBackdrop?: boolean; enableBackdropDismiss?: boolean;};
property id
id: number;
property moduleLoader
moduleLoader: ModuleLoader;
method ionViewPreLoad
ionViewPreLoad: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
class PopoverController
class PopoverController {}
PopoverController A Popover is a dialog that appears on top of the current page. It can be used for anything, but generally it is used for overflow actions that don't fit in the navigation bar.
### Creating A popover can be created by calling the
create
method. The view to display in the popover should be passed as the first argument. Any data to pass to the popover view can optionally be passed in the second argument. Options for the popover can optionally be passed in the third argument. See the [create](#create) method below for all available options.### Presenting To present a popover, call the
present
method on a PopoverController instance. In order to position the popover relative to the element clicked, a click event needs to be passed into the options of the the `present method. If the event is not passed, the popover will be positioned in the center of the current view. See the [usage](#usage) section for an example of passing this event.### Dismissing To dismiss the popover after creation, call the
dismiss()
method on thePopover
instance. The popover can also be dismissed from within the popover's view by calling thedismiss()
method on the [ViewController](../../navigation/ViewController). Thedismiss()
call accepts an optional parameter that will be passed to the callback described as follows. TheonDidDismiss(<func>)
function can be called to set up a callback action that will be performed after the popover is dismissed, receiving the parameter passed todismiss()
. The popover will dismiss when the backdrop is clicked by implicitly performingdismiss(null)
, but this can be disabled by settingenableBackdropDismiss
tofalse
in the popover options.> Note that after the component is dismissed, it will not be usable anymore and another one must be created. This can be avoided by wrapping the creation and presentation of the component in a reusable function as shown in the [usage](#usage) section below.
To open a popover on the click of a button, pass
$event
to the method which creates and presents the popover:<button ion-button icon-only (click)="presentPopover($event)"><ion-icon name="more"></ion-icon></button>import { PopoverController } from 'ionic-angular';@Component({})class MyPage {constructor(public popoverCtrl: PopoverController) {}presentPopover(myEvent) {let popover = this.popoverCtrl.create(PopoverPage);popover.present({ev: myEvent});}}The
PopoverPage
will display inside of the popover, and can be anything. Below is an example of a page with items that close the popover on click.@Component({template: `<ion-list><ion-list-header>Ionic</ion-list-header><button ion-item (click)="close()">Learn Ionic</button><button ion-item (click)="close()">Documentation</button><button ion-item (click)="close()">Showcase</button><button ion-item (click)="close()">GitHub Repo</button></ion-list>`})class PopoverPage {constructor(public viewCtrl: ViewController) {}close() {this.viewCtrl.dismiss();}}Popover Options
| Option | Type | Description | |-----------------------|------------|------------------------------------------------------------------------------------------------------------------| | cssClass |
string
| Additional classes for custom styles, separated by spaces. | | showBackdrop |boolean
| Whether to show the backdrop. Default true. | | enableBackdropDismiss |boolean
| Whether the popover should be dismissed by tapping the backdrop. Default true. |/docs/demos/src/popover/
constructor
constructor(_app: App, config: Config, _deepLinker: DeepLinker);
property config
config: Config;
method create
create: (component: any, data?: {}, opts?: PopoverOptions) => Popover;
Present a popover. See below for options
Parameter component
The Popover
Parameter data
Any data to pass to the Popover view
Parameter opts
Popover options
class RadioButton
class RadioButton extends Ion implements IonicTapInput, OnDestroy, OnInit {}
A radio button is a button that can be either checked or unchecked. A user can tap the button to check or uncheck it. It can also be checked from the template using the
checked
property.Use an element with a
radio-group
attribute to group a set of radio buttons. When radio buttons are inside a [radio group](../RadioGroup), exactly one radio button in the group can be checked at any time. If a radio button is not placed in a group, they will all have the ability to be checked at the same time.See the [Angular Forms Docs](https://angular.io/docs/ts/latest/guide/forms.html) for more information on forms and input.
<ion-list radio-group [(ngModel)]="relationship"><ion-item><ion-label>Friends</ion-label><ion-radio value="friends" checked></ion-radio></ion-item><ion-item><ion-label>Family</ion-label><ion-radio value="family"></ion-radio></ion-item><ion-item><ion-label>Enemies</ion-label><ion-radio value="enemies" [disabled]="isDisabled"></ion-radio></ion-item></ion-list>/docs/demos/src/radio/
See Also
constructor
constructor( _form: Form, config: Config, elementRef: ElementRef, renderer: Renderer, _item: Item, _group: RadioGroup);
property checked
checked: boolean;
{boolean} If true, the element is selected, and other buttons in the group are unselected.
property color
color: string;
{string} The color to use from your Sass
$colors
map. Default options are:"primary"
,"secondary"
,"danger"
,"light"
, and"dark"
. For more information, see [Theming your App](/docs/theming/theming-your-app).
property disabled
disabled: boolean;
{boolean} If true, the user cannot interact with this element.
property ionSelect
ionSelect: EventEmitter<any>;
{any} Emitted when the radio button is selected.
property value
value: any;
{any} The value of the radio button. Defaults to the generated id.
method initFocus
initFocus: () => void;
class RadioGroup
class RadioGroup {}
RadioGroup A radio group is a group of [radio buttons](../RadioButton). It allows a user to select at most one radio button from a set. Checking one radio button that belongs to a radio group unchecks any previous checked radio button within the same group.
See the [Angular Forms Docs](https://angular.io/docs/ts/latest/guide/forms.html) for more information on forms and inputs.
<ion-list radio-group [(ngModel)]="autoManufacturers"><ion-list-header>Auto Manufacturers</ion-list-header><ion-item><ion-label>Cord</ion-label><ion-radio value="cord"></ion-radio></ion-item><ion-item><ion-label>Duesenberg</ion-label><ion-radio value="duesenberg"></ion-radio></ion-item><ion-item><ion-label>Hudson</ion-label><ion-radio value="hudson"></ion-radio></ion-item><ion-item><ion-label>Packard</ion-label><ion-radio value="packard"></ion-radio></ion-item><ion-item><ion-label>Studebaker</ion-label><ion-radio value="studebaker"></ion-radio></ion-item></ion-list>/docs/demos/src/radio/
See Also
constructor
constructor( _renderer: Renderer, _elementRef: ElementRef, _cd: ChangeDetectorRef);
property disabled
disabled: boolean;
{boolean} If true, the user cannot interact with any of the buttons in the group.
property id
id: number;
property ionChange
ionChange: EventEmitter<RadioGroup>;
{any} Emitted when the selected button has changed.
property value
value: any;
method add
add: (button: RadioButton) => string;
method ngAfterContentInit
ngAfterContentInit: () => void;
method onChange
onChange: (val: any) => void;
method onTouched
onTouched: () => void;
method registerOnChange
registerOnChange: (fn: Function) => void;
method registerOnTouched
registerOnTouched: (fn: any) => void;
method remove
remove: (button: RadioButton) => void;
method setDisabledState
setDisabledState: (isDisabled: boolean) => void;
method writeValue
writeValue: (val: any) => void;
class Range
class Range extends BaseInput<any> implements AfterContentInit, ControlValueAccessor, OnDestroy {}
Range The Range slider lets users select from a range of values by moving the slider knob. It can accept dual knobs, but by default one knob controls the value of the range.
### Range Labels Labels can be placed on either side of the range by adding the
range-left
orrange-right
property to the element. The element doesn't have to be anion-label
, it can be added to any element to place it to the left or right of the range. See [usage](#usage) below for examples.### Minimum and Maximum Values Minimum and maximum values can be passed to the range through the
min
andmax
properties, respectively. By default, the range sets themin
to0
and themax
to100
.### Steps and Snaps The
step
property specifies the value granularity of the range's value. It can be useful to set thestep
when the value isn't in increments of1
. Setting thestep
property will show tick marks on the range for each step. Thesnaps
property can be set to automatically move the knob to the nearest tick mark based on the step property value.### Dual Knobs Setting the
dualKnobs
property totrue
on the range component will enable two knobs on the range. If the range has two knobs, the value will be an object containing two properties:lower
andupper
.<ion-list><ion-item><ion-range [(ngModel)]="singleValue" color="danger" pin="true"></ion-range></ion-item><ion-item><ion-range min="-200" max="200" [(ngModel)]="saturation" color="secondary"><ion-label range-left>-200</ion-label><ion-label range-right>200</ion-label></ion-range></ion-item><ion-item><ion-range min="20" max="80" step="2" [(ngModel)]="brightness"><ion-icon small range-left name="sunny"></ion-icon><ion-icon range-right name="sunny"></ion-icon></ion-range></ion-item><ion-item><ion-label>step=100, snaps, {{singleValue4}}</ion-label><ion-range min="1000" max="2000" step="100" snaps="true" color="secondary" [(ngModel)]="singleValue4"></ion-range></ion-item><ion-item><ion-label>dual, step=3, snaps, {{dualValue2 | json}}</ion-label><ion-range dualKnobs="true" [(ngModel)]="dualValue2" min="21" max="72" step="3" snaps="true"></ion-range></ion-item></ion-list>/docs/demos/src/range/
constructor
constructor( form: Form, _haptic: Haptic, item: Item, config: Config, _plt: Platform, elementRef: ElementRef, renderer: Renderer, _dom: DomController, _cd: ChangeDetectorRef);
property debounce
debounce: number;
{number} How long, in milliseconds, to wait to trigger the
ionChange
event after each change in the range value. Default0
.
property dualKnobs
dualKnobs: boolean;
{boolean} Show two knobs. Defaults to
false
.
property max
max: number;
{number} Maximum integer value of the range. Defaults to
100
.
property min
min: number;
{number} Minimum integer value of the range. Defaults to
0
.
property pin
pin: boolean;
{boolean} If true, a pin with integer value is shown when the knob is pressed. Defaults to
false
.
property ratio
readonly ratio: number;
Returns the ratio of the knob's is current location, which is a number between
0
and1
. If two knobs are used, this property represents the lower value.
property ratioUpper
readonly ratioUpper: number;
Returns the ratio of the upper value's is current location, which is a number between
0
and1
. If there is only one knob, then this will returnnull
.
property snaps
snaps: boolean;
{boolean} If true, the knob snaps to tick marks evenly spaced based on the step property value. Defaults to
false
.
property step
step: number;
{number} Specifies the value granularity. Defaults to
1
.
method ngAfterContentInit
ngAfterContentInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
class RangeKnob
class RangeKnob {}
property disabled
disabled: boolean;
property ionDecrease
ionDecrease: EventEmitter<{}>;
property ionIncrease
ionIncrease: EventEmitter<{}>;
property labelId
labelId: string;
property max
max: number;
property min
min: number;
property pin
pin: boolean;
property pressed
pressed: boolean;
property ratio
ratio: number;
property val
val: number;
class Refresher
class Refresher {}
Refresher The Refresher provides pull-to-refresh functionality on a content component. Place the
ion-refresher
as the first child of yourion-content
element.Pages can then listen to the refresher's various output events. The
refresh
output event is fired when the user has pulled down far enough to kick off the refreshing process. Once the async operation has completed and the refreshing should end, callcomplete()
.Note: Do not wrap the
ion-refresher
in a*ngIf
. It will not render properly this way. Please use theenabled
property instead to display or hide the refresher.<ion-content><ion-refresher (ionRefresh)="doRefresh($event)"><ion-refresher-content></ion-refresher-content></ion-refresher></ion-content>@Component({...})export class NewsFeedPage {doRefresh(refresher) {console.log('Begin async operation', refresher);setTimeout(() => {console.log('Async operation has ended');refresher.complete();}, 2000);}}## Refresher Content
By default, Ionic provides the pulling icon and refreshing spinner that looks best for the platform the user is on. However, you can change the default icon and spinner, along with adding text for each state by adding properties to the child
ion-refresher-content
component.```html
<ion-refresher (ionRefresh)="doRefresh($event)">
```
## Further Customizing Refresher Content
The
ion-refresher
component holds the refresh logic. It requires a child component in order to display the content. Ionic usesion-refresher-content
by default. This component displays the refresher and changes the look depending on the refresher's state. Separating these components allows developers to create their own refresher content components. You could replace our default content with custom SVG or CSS animations./docs/demos/src/refresher/
constructor
constructor( _plt: Platform, _content: Content, _zone: NgZone, gestureCtrl: GestureController);
property closeDuration
closeDuration: number;
{number} How many milliseconds it takes to close the refresher. Default is
280
.
property currentY
currentY: number;
The current touch or mouse event's Y coordinate.
property deltaY
deltaY: number;
The distance between the start of the pull and the current touch or mouse event's Y coordinate.
property enabled
enabled: boolean;
{boolean} If the refresher is enabled or not. This should be used in place of an
ngIf
. Default istrue
.
property ionPull
ionPull: EventEmitter<Refresher>;
{event} Emitted while the user is pulling down the content and exposing the refresher.
property ionRefresh
ionRefresh: EventEmitter<Refresher>;
{event} Emitted when the user lets go and has pulled down far enough, which would be farther than the
pullMin
, then your refresh hander if fired and the state is updated torefreshing
. From within your refresh handler, you must call thecomplete()
method when your async operation has completed.
property ionStart
ionStart: EventEmitter<Refresher>;
{event} Emitted when the user begins to start pulling down.
property progress
progress: number;
A number representing how far down the user has pulled. The number
0
represents the user hasn't pulled down at all. The number1
, and anything greater than1
, represents that the user has pulled far enough down that when they let go then the refresh will happen. If they let go and the number is less than1
, then the refresh will not happen, and the content will return to it's original position.
property pullMax
pullMax: number;
{number} The maximum distance of the pull until the refresher will automatically go into the
refreshing
state. By default, the pull maximum will be the result ofpullMin + 60
.
property pullMin
pullMin: number;
{number} The min distance the user must pull down until the refresher can go into the
refreshing
state. Default is60
.
property snapbackDuration
snapbackDuration: number;
{number} How many milliseconds it takes the refresher to to snap back to the
refreshing
state. Default is280
.
property startY
startY: number;
The Y coordinate of where the user started to the pull down the content.
property state
state: string;
The current state which the refresher is in. The refresher's states include:
-
inactive
- The refresher is not being pulled down or refreshing and is currently hidden. -pulling
- The user is actively pulling down the refresher, but has not reached the point yet that if the user lets go, it'll refresh. -cancelling
- The user pulled down the refresher and let go, but did not pull down far enough to kick off therefreshing
state. After letting go, the refresher is in thecancelling
state while it is closing, and will go back to theinactive
state once closed. -ready
- The user has pulled down the refresher far enough that if they let go, it'll begin therefreshing
state. -refreshing
- The refresher is actively waiting on the async operation to end. Once the refresh handler callscomplete()
it will begin thecompleting
state. -completing
- Therefreshing
state has finished and the refresher is in the process of closing itself. Once closed, the refresher will go back to theinactive
state.
method cancel
cancel: () => void;
Changes the refresher's state from
refreshing
tocancelling
.
method complete
complete: () => void;
Call
complete()
when your async operation has completed. For example, therefreshing
state is while the app is performing an asynchronous operation, such as receiving more data from an AJAX request. Once the data has been received, you then call this method to signify that the refreshing has completed and to close the refresher. This method also changes the refresher's state fromrefreshing
tocompleting
.
method ngOnDestroy
ngOnDestroy: () => void;
method ngOnInit
ngOnInit: () => void;
class RefresherContent
class RefresherContent {}
constructor
constructor(r: Refresher, _config: Config);
property pullingIcon
pullingIcon: string;
{string} a static icon to display when you begin to pull down
property pullingText
pullingText: string;
{string} the text you want to display when you begin to pull down
property r
r: Refresher;
property refreshingSpinner
refreshingSpinner: string;
{string} An animated SVG spinner that shows when refreshing begins
property refreshingText
refreshingText: string;
{string} the text you want to display when performing a refresh
method ngOnInit
ngOnInit: () => void;
class Reorder
class Reorder {}
constructor
constructor(elementRef: ElementRef);
method getReorderNode
getReorderNode: () => HTMLElement;
method onClick
onClick: (ev: UIEvent) => void;
class RootNode
abstract class RootNode {}
method getElementRef
abstract getElementRef: () => ElementRef;
method initPane
abstract initPane: () => boolean;
method paneChanged
abstract paneChanged: (visible: boolean) => void;
class Row
class Row {}
Row ionic
Rows are horizontal components of the [grid](../Grid) system and contain varying numbers of [columns](../Col). They ensure the columns are positioned properly.
## Row attributes
By default, columns will stretch to fill the entire height of the row and wrap when necessary. There are several attributes that can be added to a row to customize this behavior.
| Property | Description | |-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------| | nowrap | Adds
flex-wrap: nowrap
. Forces the columns to a single row. | | wrap-reverse | Addsflex-wrap: wrap-reverse
. The columns will wrap in reverse. | | align-items-start | Addsalign-items: flex-start
. All columns will be vertically aligned at the top, unless they specify their own alignment. | | align-items-center | Addsalign-items: center
. All columns will be vertically aligned in the center, unless they specify their own alignment. | | align-items-end | Addsalign-items: flex-end
. All columns will be vertically aligned at the bottom, unless they specify their own alignment. | | align-items-stretch | Addsalign-items: stretch
. All columns will be stretched to take up the entire height of the row, unless they specify their own alignment. | | align-items-baseline | Addsalign-items: baseline
. All columns will be vertically aligned at their baselines, unless they specify their own alignment. | | justify-content-start | Addsjustify-content: start
. All columns will be horizontally aligned at the start. | | justify-content-center | Addsjustify-content: center
. All columns will be horizontally aligned at the center. | | justify-content-end | Addsjustify-content: end
. All columns will be horizontally aligned at the end. | | justify-content-around | Addsjustify-content: space-around
. All columns will be horizontally aligned with equal space around them. | | justify-content-between | Addsjustify-content: space-between
. All columns will be horizontally aligned with a half-size space on either end. |
class Scroll
class Scroll {}
Scroll Scroll is a non-flexboxed scroll area that can scroll horizontally or vertically.
ion-Scroll
Can be used in places where you may not need a full page scroller, but a highly customized one, such as image scubber or comment scroller.<ion-scroll scrollX="true"></ion-scroll><ion-scroll scrollY="true"></ion-scroll><ion-scroll scrollX="true" scrollY="true"></ion-scroll>/docs/demos/src/scroll/
constructor
constructor();
property maxScale
maxScale: number;
property maxZoom
maxZoom: any;
{number} Set the max zoom amount.
property scrollX
scrollX: any;
{boolean} If true, scrolling along the X axis is enabled.
property scrollY
scrollY: any;
{boolean} If true, scrolling along the Y axis is enabled; requires the following CSS declaration: ion-scroll { white-space: nowrap; }
property zoom
zoom: any;
{boolean} If true, zooming is enabled.
property zoomDuration
zoomDuration: number;
method addScrollEventListener
addScrollEventListener: (handler: any) => () => void;
Add a scroll event handler to the scroll element if it exists.
Parameter handler
The scroll handler to add to the scroll element.
Returns
{?Function} a function to remove the specified handler, otherwise undefined if the scroll element doesn't exist.
class Searchbar
class Searchbar extends BaseInput<string> {}
Searchbar ionic Manages the display of a Searchbar which can be used to search or filter items.
<ion-searchbar[(ngModel)]="myInput"[showCancelButton]="shouldShowCancel"(ionInput)="onInput($event)"(ionCancel)="onCancel($event)"></ion-searchbar>/docs/demos/src/searchbar/
See Also
constructor
constructor( config: Config, _plt: Platform, elementRef: ElementRef, renderer: Renderer, ngControl: NgControl);
property animated
animated: boolean;
{boolean} If true, enable searchbar animation. Default
false
.
property autocomplete
autocomplete: string;
{string} Set the input's autocomplete property. Values:
"on"
,"off"
. Default"off"
.
property autocorrect
autocorrect: string;
{string} Set the input's autocorrect property. Values:
"on"
,"off"
. Default"off"
.
property cancelButtonText
cancelButtonText: string;
{string} Set the the cancel button text. Default:
"Cancel"
.
property debounce
debounce: number;
{number} How long, in milliseconds, to wait to trigger the
ionInput
event after each keystroke. Default250
.
property ionCancel
ionCancel: EventEmitter<UIEvent>;
{event} Emitted when the cancel button is clicked.
property ionClear
ionClear: EventEmitter<UIEvent>;
{event} Emitted when the clear input button is clicked.
property ionInput
ionInput: EventEmitter<UIEvent>;
{event} Emitted when the Searchbar input has changed, including when it's cleared.
property placeholder
placeholder: string;
{string} Set the input's placeholder. Default
"Search"
.
property showCancelButton
showCancelButton: boolean;
{boolean} If true, show the cancel button. Default
false
.
property spellcheck
spellcheck: string | boolean;
{string|boolean} Set the input's spellcheck property. Values:
true
,false
. Defaultfalse
.
property type
type: string;
{string} Set the type of the input. Values:
"text"
,"password"
,"email"
,"number"
,"search"
,"tel"
,"url"
. Default"search"
.
method cancelSearchbar
cancelSearchbar: (ev: UIEvent) => void;
Clears the input field and tells the input to blur since the clearInput function doesn't want the input to blur then calls the custom cancel function if the user passed one in.
method clearInput
clearInput: (ev: UIEvent) => void;
Clears the input field and triggers the control change.
method inputBlurred
inputBlurred: () => void;
Sets the Searchbar to not focused and checks if it should align left based on whether there is a value in the searchbar or not.
method inputChanged
inputChanged: (ev: any) => void;
Update the Searchbar input value when the input changes
method inputFocused
inputFocused: () => void;
Sets the Searchbar to focused and active on input focus.
method ngOnInit
ngOnInit: () => void;
On Initialization check for attributes
method positionCancelButton
positionCancelButton: () => void;
Show the iOS Cancel button on focus, hide it offscreen otherwise
method positionElements
positionElements: () => void;
Positions the input search icon, placeholder, and the cancel button based on the input value and if it is focused. (ios only)
method positionPlaceholder
positionPlaceholder: () => void;
method setFocus
setFocus: () => void;
class Segment
class Segment extends BaseInput<string> implements AfterContentInit {}
Segment A Segment is a group of buttons, sometimes known as Segmented Controls, that allow the user to interact with a compact group of a number of controls. Segments provide functionality similar to tabs, selecting one will unselect all others. You should use a tab bar instead of a segmented control when you want to let the user move back and forth between distinct pages in your app. You could use Angular's
ngModel
orFormBuilder
API. For an overview on howFormBuilder
works, checkout [Angular Forms](http://learnangular2.com/forms/), or [Angular FormBuilder](https://angular.io/docs/ts/latest/api/forms/index/FormBuilder-class.html)<!-- Segment in a header --><ion-header><ion-toolbar><ion-segment [(ngModel)]="icons" color="secondary"><ion-segment-button value="camera"><ion-icon name="camera"></ion-icon></ion-segment-button><ion-segment-button value="bookmark"><ion-icon name="bookmark"></ion-icon></ion-segment-button></ion-segment></ion-toolbar></ion-header><ion-content><!-- Segment in content with material design mode on all devices --><ion-segment [(ngModel)]="relationship" color="primary" mode="md" (ionChange)="segmentChanged($event)"><ion-segment-button value="friends">Friends</ion-segment-button><ion-segment-button value="enemies">Enemies</ion-segment-button></ion-segment><!-- Segment in a form --><form [formGroup]="myForm"><ion-segment formControlName="mapStyle" color="danger"><ion-segment-button value="standard">Standard</ion-segment-button><ion-segment-button value="hybrid">Hybrid</ion-segment-button><ion-segment-button value="sat">Satellite</ion-segment-button></ion-segment></form></ion-content>/docs/demos/src/segment/
See Also
[Angular Forms](http://learnangular2.com/forms/)
constructor
constructor( config: Config, elementRef: ElementRef, renderer: Renderer, ngControl: NgControl);
method ngAfterContentInit
ngAfterContentInit: () => void;
class SegmentButton
class SegmentButton {}
SegmentButton The child buttons of the
ion-segment
component. Eachion-segment-button
must have a value.<ion-content><!-- Segment buttons with icons --><ion-segment [(ngModel)]="icons" color="secondary"><ion-segment-button value="camera"><ion-icon name="camera"></ion-icon></ion-segment-button><ion-segment-button value="bookmark"><ion-icon name="bookmark"></ion-icon></ion-segment-button></ion-segment><!-- Segment buttons with text --><ion-segment [(ngModel)]="relationship" color="primary"><ion-segment-button value="friends" (ionSelect)="selectedFriends()">Friends</ion-segment-button><ion-segment-button value="enemies" (ionSelect)="selectedEnemies()">Enemies</ion-segment-button></ion-segment></ion-content>/docs/demos/src/segment/
See Also
constructor
constructor();
property disabled
disabled: boolean;
{boolean} If true, the user cannot interact with this element.
property ionSelect
ionSelect: EventEmitter<SegmentButton>;
{SegmentButton} Emitted when a segment button has been clicked.
property isActive
isActive: boolean;
property value
value: string;
{string} the value of the segment button. Required.
method ngOnInit
ngOnInit: () => void;
method onClick
onClick: () => void;
On click of a SegmentButton
class Select
class Select extends BaseInput<any> implements OnDestroy {}
Select The
ion-select
component is similar to an HTML<select>
element, however, Ionic's select component makes it easier for users to sort through and select the preferred option or options. When users tap the select component, a dialog will appear with all of the options in a large, easy to select list for users.The select component takes child
ion-option
components. Ifion-option
is not given avalue
attribute then it will use its text as the value.If
ngModel
is bound toion-select
, the selected value will be based on the bound value of the model. Otherwise, theselected
attribute can be used onion-option
components.### Interfaces
By default, the
ion-select
uses the to open up the overlay of options in an alert. The interface can be changed to use the or by passingaction-sheet
orpopover
, respectively, to theinterface
property. Read on to the other sections for the limitations of the different interfaces.### Single Value: Radio Buttons
The standard
ion-select
component allows the user to select only one option. When selecting only one option the alert interface presents users with a radio button styled list of options. The action sheet interface can only be used with a single value select. If the number of options exceed 6, it will use thealert
interface even ifaction-sheet
is passed. Theion-select
component's value receives the value of the selected option's value.<ion-item><ion-label>Gender</ion-label><ion-select [(ngModel)]="gender"><ion-option value="f">Female</ion-option><ion-option value="m">Male</ion-option></ion-select></ion-item>### Multiple Value: Checkboxes
By adding the
multiple="true"
attribute toion-select
, users are able to select multiple options. When multiple options can be selected, the alert overlay presents users with a checkbox styled list of options. Theion-select multiple="true"
component's value receives an array of all the selected option values. In the example below, because each option is not given avalue
, then it'll use its text as the value instead.Note: the
action-sheet
andpopover
interfaces will not work with a multi-value select.<ion-item><ion-label>Toppings</ion-label><ion-select [(ngModel)]="toppings" multiple="true"><ion-option>Bacon</ion-option><ion-option>Black Olives</ion-option><ion-option>Extra Cheese</ion-option><ion-option>Mushrooms</ion-option><ion-option>Pepperoni</ion-option><ion-option>Sausage</ion-option></ion-select></ion-item>### Select Buttons By default, the two buttons read
Cancel
andOK
. Each button's text can be customized using thecancelText
andokText
attributes:<ion-select okText="Okay" cancelText="Dismiss">...</ion-select>The
action-sheet
andpopover
interfaces do not have anOK
button, clicking on any of the options will automatically close the overlay and select that value.### Select Options
Since
ion-select
uses theAlert
,Action Sheet
andPopover
interfaces, options can be passed to these components through theselectOptions
property. This can be used to pass a custom title, subtitle, css class, and more. See the , , and for the properties that each interface accepts.For example, to change the
mode
of the overlay, pass it intoselectOptions
.<ion-select [selectOptions]="selectOptions">...</ion-select>this.selectOptions = {title: 'Pizza Toppings',subTitle: 'Select your toppings',mode: 'md'};### Object Value References
When using objects for select values, it is possible for the identities of these objects to change if they are coming from a server or database, while the selected value's identity remains the same. For example, this can occur when an existing record with the desired object value is loaded into the select, but the newly retrieved select options now have different identities. This will result in the select appearing to have no value at all, even though the original selection in still intact.
Using the
compareWith
Input
is the solution to this problem<ion-item><ion-label>Employee</ion-label><ion-select [(ngModel)]="employee" [compareWith]="compareFn"><ion-option *ngFor="let employee of employees" [value]="employee">{{employee.name}}</ion-option></ion-select></ion-item>compareFn(e1: Employee, e2: Employee): boolean {return e1 && e2 ? e1.id === e2.id : e1 === e2;}/docs/demos/src/select/
constructor
constructor( _app: App, form: Form, config: Config, elementRef: ElementRef, renderer: Renderer, item: Item, deepLinker: DeepLinker);
property cancelText
cancelText: string;
{string} The text to display on the cancel button. Default:
Cancel
.
property compareWith
compareWith: (o1: any, o2: any) => boolean;
{Function} The function that will be called to compare object values
property config
config: Config;
property deepLinker
deepLinker: DeepLinker;
property interface
interface: string;
{string} The interface the select should use:
action-sheet
,popover
oralert
. Default:alert
.
property ionCancel
ionCancel: EventEmitter<Select>;
{any} Emitted when the selection was cancelled.
property multiple
multiple: any;
{boolean} If true, the element can accept multiple values.
property okText
okText: string;
{string} The text to display on the ok button. Default:
OK
.
property options
options: QueryList<Option>;
property placeholder
placeholder: string;
{string} The text to display when the select is empty.
property selectedText
selectedText: string;
{string} The text to display instead of the selected option's value.
property selectOptions
selectOptions: any;
{any} Any additional options that the
alert
oraction-sheet
interface can take. See the [AlertController API docs](../../alert/AlertController/#create) and the [ActionSheetController API docs](../../action-sheet/ActionSheetController/#create) for the create options for each interface.
property text
readonly text: string | string[];
method close
close: () => Promise<any>;
Close the select interface.
method getValues
getValues: () => any[];
method open
open: (ev?: UIEvent) => void;
Open the select interface.
class SelectPopover
class SelectPopover implements OnInit {}
constructor
constructor(navParams: NavParams, viewController: ViewController);
property options
options: SelectPopoverOption[];
property value
value: any;
method ngOnInit
ngOnInit: () => void;
class ShowWhen
class ShowWhen extends DisplayWhen {}
ShowWhen The
showWhen
attribute takes a string that represents a platform or screen orientation. The element the attribute is added to will only be shown when that platform or screen orientation is active.Complements the [hideWhen attribute](../HideWhen). If the
showWhen
attribute is used on an element that also has thehideWhen
attribute, the element will not show ifhideWhen
evaluates totrue
orshowWhen
evaluates tofalse
. If thehidden
attribute is also added, the element will not show ifhidden
evaluates totrue
.View the [Platform API docs](../../../platform/Platform) for more information on the different platforms you can use.
<div showWhen="android">I am visible on Android!</div><div showWhen="ios">I am visible on iOS!</div><div showWhen="android,ios">I am visible on Android and iOS!</div><div showWhen="portrait">I am visible on Portrait!</div><div showWhen="landscape">I am visible on Landscape!</div>/docs/demos/src/show-when/
See Also
constructor
constructor(showWhen: string, plt: Platform, zone: NgZone);
class Slide
class Slide {}
Slide The Slide component is a child component of [Slides](../Slides). The template should be written as
ion-slide
. Any slide content should be written in this component and it should be used in conjunction with [Slides](../Slides).See the [Slides API Docs](../Slides) for more usage information.
/docs/demos/src/slides/
See Also
constructor
constructor(elementRef: ElementRef, renderer: Renderer, _slides: Slides);
method ngOnDestroy
ngOnDestroy: () => void;
class SlideEdgeGesture
class SlideEdgeGesture extends SlideGesture {}
constructor
constructor(plt: Platform, element: HTMLElement, opts?: any);
property edges
edges: string[];
property maxEdgeStart
maxEdgeStart: any;
method canStart
canStart: (ev: any) => boolean;
method getContainerDimensions
getContainerDimensions: () => { left: number; top: number; width: number; height: number;};
method setEdges
setEdges: (edges: string) => void;
class SlideGesture
class SlideGesture extends PanGesture {}
constructor
constructor(plt: Platform, element: HTMLElement, opts?: {});
property slide
slide: SlideData;
method getElementStartPos
getElementStartPos: (_slide: SlideData, _ev: any) => number;
method getSlideBoundaries
getSlideBoundaries: ( _slide: SlideData, _ev: any) => { min: number; max: number };
method onDragEnd
onDragEnd: (ev: any) => void;
method onDragMove
onDragMove: (ev: any) => void;
method onDragStart
onDragStart: (ev: any) => void;
method onSlide
onSlide: (_slide?: SlideData, _ev?: any) => void;
method onSlideBeforeStart
onSlideBeforeStart: (_ev?: any) => void;
method onSlideEnd
onSlideEnd: (_slide?: SlideData, _ev?: any) => void;
method onSlideStart
onSlideStart: (_slide?: SlideData, _ev?: any) => void;
class Slides
class Slides extends Ion {}
Slides The Slides component is a multi-section container. Each section can be swiped or dragged between. It contains any number of [Slide](../Slide) components.
### Creating You should use a template to create slides and listen to slide events. The template should contain the slide container, an
<ion-slides>
element, and any number of [Slide](../Slide) components, written as<ion-slide>
. Basic configuration values can be set as input properties, which are listed below. Slides events can also be listened to such as the slide changing by placing the event on the<ion-slides>
element. See [Usage](#usage) below for more information.### Navigating After creating and configuring the slides, you can navigate between them by swiping or calling methods on the
Slides
instance. You can callslideTo()
to navigate to a specific slide, orslideNext()
to change to the slide that follows the active slide. All of the [methods](#instance-members) provided by theSlides
instance are listed below. See [Usage](#usage) below for more information on navigating between slides.You can add slides to a
@Component
using the following template:<ion-slides><ion-slide><h1>Slide 1</h1></ion-slide><ion-slide><h1>Slide 2</h1></ion-slide><ion-slide><h1>Slide 3</h1></ion-slide></ion-slides>Next, we can use
ViewChild
to assign the Slides instance to yourslides
property. Now we can call any of theSlides
[methods](#instance-members), for example we can use the Slide'sslideTo()
method in order to navigate to a specific slide on a button click. Below we call thegoToSlide()
method and it navigates to the 3rd slide:import { ViewChild } from '@angular/core';import { Slides } from 'ionic-angular';class MyPage {@ViewChild(Slides) slides: Slides;goToSlide() {this.slides.slideTo(2, 500);}}We can also add events to listen to on the
<ion-slides>
element. Let's add theionSlideDidChange
event and call a method when the slide changes:<ion-slides (ionSlideDidChange)="slideChanged()">In our class, we add the
slideChanged()
method which gets the active index and prints it:class MyPage {...slideChanged() {let currentIndex = this.slides.getActiveIndex();console.log('Current index is', currentIndex);}}### Zooming If your slides contain images, you can enable zooming on them by setting `zoom="true" and wrapping each image in a
div
with the classswiper-zoom-container
. Zoom supportsimg
,svg
,canvas
, andion-img
.<ion-slides zoom="true"><ion-slide><div class="swiper-zoom-container"><img src="assets/img/dog.jpg"></div><ion-label>Woof</ion-label></ion-slide><ion-slide><div class="swiper-zoom-container"><img src="assets/img/cat.jpg"></div><ion-label>Meow</ion-label></ion-slide><ion-slide><div class="swiper-zoom-container"><img src="assets/img/fish.jpg"></div><ion-label>Just keep swimming</ion-label></ion-slide></ion-slides>There are several options available to create customized slides. Ionic exposes the most commonly used options as [inputs](http://learnangular2.com/inputs/). In order to use an option that isn't exposed as an input the following code should be used, where
freeMode
is the option to change:import { ViewChild } from '@angular/core';import { Slides } from 'ionic-angular';class MyPage {@ViewChild(Slides) slides: Slides;ngAfterViewInit() {this.slides.freeMode = true;}}To see all of the available options, take a look at the [source for slides](https://github.com/ionic-team/ionic/blob/v3/src/components/slides/slides.ts).
/docs/demos/src/slides/
See Also
Adopted from Swiper.js: The most modern mobile touch slider and framework with hardware accelerated transitions.
http://www.idangero.us/swiper/
Copyright 2016, Vladimir Kharlampidi The iDangero.us http://www.idangero.us/
Licensed under MIT
constructor
constructor( config: Config, _plt: Platform, zone: NgZone, viewCtrl: ViewController, elementRef: ElementRef, renderer: Renderer);
property autoHeight
autoHeight: boolean;
property autoplay
autoplay: any;
{number} Delay between transitions (in milliseconds). If this parameter is not passed, autoplay is disabled. Default does not have a value and does not autoplay. Default:
null
.
property autoplayDisableOnInteraction
autoplayDisableOnInteraction: boolean;
property autoplayStopOnLast
autoplayStopOnLast: boolean;
property centeredSlides
centeredSlides: boolean;
{boolean} Center a slide in the middle of the screen.
property clickedIndex
clickedIndex: number;
property clickedSlide
clickedSlide: SlideElement;
property container
container: SlideContainer;
property control
control: Slides | Slides[];
{Slides} Pass another Slides instance or array of Slides instances that should be controlled by this Slides instance. Default:
null
.
property controlBy
controlBy: string;
property controlInverse
controlInverse: boolean;
property coverflow
coverflow: { rotate: number; stretch: number; depth: number; modifier: number; slideShadows: boolean;};
property cube
cube: { slideShadows: boolean; shadow: boolean; shadowOffset: number; shadowScale: number;};
property dir
dir: string;
{string} If dir attribute is equal to rtl, set interal _rtl to true;
property direction
direction: string;
{string} Swipe direction: 'horizontal' or 'vertical'. Default:
horizontal
.
property effect
effect: string;
{string} The animation effect of the slides. Possible values are:
slide
,fade
,cube
,coverflow
orflip
. Default:slide
.
property fade
fade: { crossFade: boolean };
property firstSlideMessage
firstSlideMessage: string;
property flip
flip: { slideShadows: boolean; limitRotation: boolean };
property followFinger
followFinger: boolean;
property freeMode
freeMode: boolean;
property freeModeMinimumVelocity
freeModeMinimumVelocity: number;
property freeModeMomentum
freeModeMomentum: boolean;
property freeModeMomentumBounce
freeModeMomentumBounce: boolean;
property freeModeMomentumBounceRatio
freeModeMomentumBounceRatio: number;
property freeModeMomentumRatio
freeModeMomentumRatio: number;
property freeModeMomentumVelocityRatio
freeModeMomentumVelocityRatio: number;
property freeModeSticky
freeModeSticky: boolean;
property height
height: number;
Height of container.
property id
id: number;
property initialSlide
initialSlide: any;
{number} Index number of initial slide. Default:
0
.
property ionSlideAutoplay
ionSlideAutoplay: EventEmitter<Slides>;
{Slides} Emitted when a slide moves.
property ionSlideAutoplayStart
ionSlideAutoplayStart: EventEmitter<Slides>;
{Slides} Emitted when a autoplay starts.
property ionSlideAutoplayStop
ionSlideAutoplayStop: EventEmitter<Slides>;
{Slides} Emitted when a autoplay stops.
property ionSlideDidChange
ionSlideDidChange: EventEmitter<Slides>;
{Slides} Emitted when a slide change ends.
property ionSlideDoubleTap
ionSlideDoubleTap: EventEmitter<Slides>;
{Slides} Emitted when the user double taps on the slide's container.
property ionSlideDrag
ionSlideDrag: EventEmitter<Slides>;
{Slides} Emitted when a slide moves.
property ionSlideNextEnd
ionSlideNextEnd: EventEmitter<Slides>;
{Slides} Emitted when a slide change ends with the "forward" direction.
property ionSlideNextStart
ionSlideNextStart: EventEmitter<Slides>;
{Slides} Emitted when a slide change starts with the "forward" direction.
property ionSlidePrevEnd
ionSlidePrevEnd: EventEmitter<Slides>;
{Slides} Emitted when a slide change ends with the "backward" direction.
property ionSlidePrevStart
ionSlidePrevStart: EventEmitter<Slides>;
{Slides} Emitted when a slide change starts with the "backward" direction.
property ionSlideProgress
ionSlideProgress: EventEmitter<number>;
property ionSlideReachEnd
ionSlideReachEnd: EventEmitter<Slides>;
{Slides} Emitted when slides reaches its last slide.
property ionSlideReachStart
ionSlideReachStart: EventEmitter<Slides>;
{Slides} Emitted when slides reaches its beginning (initial position).
property ionSlideTap
ionSlideTap: EventEmitter<Slides>;
{Slides} Emitted when the user taps/clicks on the slide's container.
property ionSlideTouchEnd
ionSlideTouchEnd: EventEmitter<TouchEvent>;
property ionSlideTouchStart
ionSlideTouchStart: EventEmitter<TouchEvent>;
property ionSlideTransitionEnd
ionSlideTransitionEnd: EventEmitter<Slides>;
property ionSlideTransitionStart
ionSlideTransitionStart: EventEmitter<Slides>;
property ionSlideWillChange
ionSlideWillChange: EventEmitter<Slides>;
{Slides} Emitted when a slide change starts.
property iOSEdgeSwipeDetection
iOSEdgeSwipeDetection: boolean;
property iOSEdgeSwipeThreshold
iOSEdgeSwipeThreshold: number;
property keyboardControl
keyboardControl: boolean;
property lastSlideMessage
lastSlideMessage: string;
property longSwipes
longSwipes: boolean;
property longSwipesMs
longSwipesMs: number;
property longSwipesRatio
longSwipesRatio: number;
property loop
loop: boolean;
{boolean} If true, continuously loop from the last slide to the first slide.
property loopAdditionalSlides
loopAdditionalSlides: number;
property loopedSlides
loopedSlides: number;
property nextButton
nextButton: HTMLElement;
property nextSlideMessage
nextSlideMessage: string;
property noSwiping
noSwiping: boolean;
property onlyExternal
onlyExternal: boolean;
property originalEvent
originalEvent: any;
property pager
pager: boolean;
{boolean} If true, show the pager.
property paginationBulletRender
paginationBulletRender: (index?: number, cssClass?: string) => void;
property paginationClickable
paginationClickable: boolean;
property paginationHide
paginationHide: boolean;
property paginationType
paginationType: string;
{string} Type of pagination. Possible values are:
bullets
,fraction
,progress
. Default:bullets
. (Note that the pager will not show unlesspager
input is set to true).
property parallax
parallax: boolean;
{boolean} If true, allows you to use "parallaxed" elements inside of slider.
property prevButton
prevButton: HTMLElement;
property preventClicks
preventClicks: boolean;
property preventClicksPropagation
preventClicksPropagation: boolean;
property prevSlideMessage
prevSlideMessage: string;
property progress
progress: number;
property realIndex
realIndex: number;
property renderedHeight
renderedHeight: number;
property renderedWidth
renderedWidth: number;
property resistance
resistance: boolean;
property resistanceRatio
resistanceRatio: number;
property roundLengths
roundLengths: boolean;
Set to true to round values of slides width and height to prevent blurry texts on usual resolution screens (if you have such)
property runCallbacksOnInit
runCallbacksOnInit: boolean;
property setWrapperSize
setWrapperSize: boolean;
property shortSwipes
shortSwipes: boolean;
property simulateTouch
simulateTouch: boolean;
property slideId
slideId: string;
property slidesOffsetAfter
slidesOffsetAfter: number;
property slidesOffsetBefore
slidesOffsetBefore: number;
property slidesPerColumn
slidesPerColumn: number;
property slidesPerColumnFill
slidesPerColumnFill: string;
property slidesPerGroup
slidesPerGroup: number;
property slidesPerView
slidesPerView: any;
{number} Slides per view. Slides visible at the same time. Default:
1
.
property slideToClickedSlide
slideToClickedSlide: boolean;
property spaceBetween
spaceBetween: any;
{number} Distance between slides in px. Default:
0
.
property speed
speed: any;
{number} Duration of transition between slides (in milliseconds). Default:
300
.
property swipeDirection
swipeDirection: string;
property swipeHandler
swipeHandler: any;
property threshold
threshold: number;
property touchAngle
touchAngle: number;
property touchEventsTarget
touchEventsTarget: string;
property touchMoveStopPropagation
touchMoveStopPropagation: boolean;
property touchRatio
touchRatio: number;
property touchReleaseOnEdges
touchReleaseOnEdges: boolean;
property velocity
velocity: number;
property virtualTranslate
virtualTranslate: boolean;
Enabled this option and swiper will be operated as usual except it will not move, real translate values on wrapper will not be set. Useful when you may need to create custom slide transition.
property watchSlidesProgress
watchSlidesProgress: boolean;
property watchSlidesVisibility
watchSlidesVisibility: boolean;
property width
width: number;
Width of container.
property zoom
zoom: boolean;
{boolean} If true, enables zooming functionality.
property zoomMax
zoomMax: number;
property zoomMin
zoomMin: number;
property zoomToggle
zoomToggle: boolean;
method enableKeyboardControl
enableKeyboardControl: (shouldEnableKeyboard: boolean) => void;
Enable or disable keyboard control.
Parameter shouldEnableKeyboard
If set to true the slider can be controled by a keyboard.
method getActiveIndex
getActiveIndex: () => number;
Get the index of the active slide.
Returns
{number} The index number of the current slide.
method getPreviousIndex
getPreviousIndex: () => number;
Get the index of the previous slide.
Returns
{number} The index number of the previous slide.
method isBeginning
isBeginning: () => boolean;
Get whether or not the current slide is the first slide.
Returns
{boolean} If the slide is the first slide or not.
method isEnd
isEnd: () => boolean;
Get whether or not the current slide is the last slide.
Returns
{boolean} If the slide is the last slide or not.
method length
length: () => number;
Get the total number of slides.
Returns
{number} The total number of slides.
method lockSwipes
lockSwipes: (shouldLockSwipes: boolean) => void;
Lock or unlock the ability to slide to change slides.
Parameter shouldLockSwipes
If set to true user can not swipe in either direction on slide. False allows swiping in both directions.
method lockSwipeToNext
lockSwipeToNext: (shouldLockSwipeToNext: boolean) => void;
Lock or unlock the ability to slide to the next slides.
Parameter shouldLockSwipeToNext
If set to true the user will not be able to swipe to the next slide. Set to false to unlock this behaviour.
method lockSwipeToPrev
lockSwipeToPrev: (shouldLockSwipeToPrev: boolean) => void;
Lock or unlock the ability to slide to the previous slides.
Parameter shouldLockSwipeToPrev
If set to true the user will not be able to swipe to the previous slide. Set to false to unlock this behaviour.
method ngAfterContentInit
ngAfterContentInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method resize
resize: () => void;
method slideNext
slideNext: (speed?: number, runCallbacks?: boolean) => void;
Transition to the next slide.
Parameter speed
Transition duration (in ms).
Parameter runCallbacks
Whether or not to emit the
ionSlideWillChange
/ionSlideDidChange
events. Default true.
method slidePrev
slidePrev: (speed?: number, runCallbacks?: boolean) => void;
Transition to the previous slide.
Parameter speed
Transition duration (in ms).
Parameter runCallbacks
Whether or not to emit the
ionSlideWillChange
/ionSlideDidChange
events. Default true.
method slideTo
slideTo: (index: number, speed?: number, runCallbacks?: boolean) => void;
Transition to the specified slide.
Parameter index
The index number of the slide.
Parameter speed
Transition duration (in ms).
Parameter runCallbacks
Whether or not to emit the
ionSlideWillChange
/ionSlideDidChange
events. Default true.
method startAutoplay
startAutoplay: () => void;
Start auto play.
method stopAutoplay
stopAutoplay: () => void;
Stop auto play.
method update
update: (debounce?: number) => void;
Update the underlying slider implementation. Call this if you've added or removed child slides.
class Spinner
class Spinner extends Ion {}
Spinner The
ion-spinner
component provides a variety of animated SVG spinners. Spinners enables you to give users feedback that the app is actively processing/thinking/waiting/chillin’ out, or whatever you’d like it to indicate. By default, theion-refresher
feature uses this spinner component while it's the refresher is in therefreshing
state.Ionic offers a handful of spinners out of the box, and by default, it will use the appropriate spinner for the platform on which it’s running.
ios ios-small bubbles circles crescent dots
The following code would use the default spinner for the platform it's running from. If it's neither iOS or Android, it'll default to use
ios
.<ion-spinner></ion-spinner>By setting the
name
property, you can specify which predefined spinner to use, no matter what the platform is.<ion-spinner name="bubbles"></ion-spinner>## Styling SVG with CSS One cool thing about SVG is its ability to be styled with CSS! One thing to note is that some of the CSS properties on an SVG element have different names. For example, SVG uses the term
stroke
instead ofborder
, andfill
instead ofbackground-color
.ion-spinner * {width: 28px;height: 28px;stroke: #444;fill: #222;}
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
property duration
duration: number;
{string} How long it takes it to do one loop.
property name
name: string;
{string} SVG spinner name.
property paused
paused: boolean;
{boolean} If true, pause the animation.
method load
load: () => void;
method ngOnInit
ngOnInit: () => void;
class SplitPane
class SplitPane extends Ion implements RootNode {}
SplitPane
SplitPane is a component that makes it possible to create multi-view layout. Similar to iPad apps, SplitPane allows UI elements, like Menus, to be displayed as the viewport increases.
If the devices screen size is below a certain size, the SplitPane will collapse and the menu will become hidden again. This is especially useful when creating an app that will be served over a browser or deployed through the app store to phones and tablets.
To use SplitPane, simply add the component around your root component. In this example, we'll be using a sidemenu layout, similar to what is provided from the sidemenu starter template.
```html <!-- our side menu --> <ion-menu [content]="content"> Menu
<!-- the main content --> <ion-nav [root]="root" main #content> ```
Here, SplitPane will look for the element with the
main
attribute and make that the central component on larger screens. Themain
component can be any Ionic component (ion-nav
orion-tabs
) exception-menu
.### Setting breakpoints
By default, SplitPane will expand when the screen is larger than 768px. If you want to customize this, use the
when
input. Thewhen
input can accept any valid media query, as it usesmatchMedia()
underneath.```
<!-- our side menu --> <ion-menu [content]="content"> ....
<!-- the main content --> <ion-nav [root]="root" main #content> ```
SplitPane also provides some predefined media queries that can be used.
```html <!-- could be "xs", "sm", "md", "lg", or "xl" --> ... ```
| Size | Value | Description | |------|-----------------------|-----------------------------------------------------------------------| |
xs
|(min-width: 0px)
| Show the split-pane when the min-width is 0px (meaning, always) | |sm
|(min-width: 576px)
| Show the split-pane when the min-width is 576px | |md
|(min-width: 768px)
| Show the split-pane when the min-width is 768px (default break point) | |lg
|(min-width: 992px)
| Show the split-pane when the min-width is 992px | |xl
|(min-width: 1200px)
| Show the split-pane when the min-width is 1200px |You can also pass in boolean values that will trigger SplitPane when the value or expression evaluates to true.
```html <ion-split-pane [when]="isLarge"> ... ```
```ts class MyClass { public isLarge = false; constructor(){} } ```
Or
```html <ion-split-pane [when]="shouldShow()"> ... ```
```ts class MyClass { constructor(){} shouldShow(){ if(conditionA){ return true } else { return false } } } ```
constructor
constructor( _zone: NgZone, _plt: Platform, config: Config, elementRef: ElementRef, renderer: Renderer);
property enabled
enabled: boolean;
{boolean} If
false
, the split-pane is disabled, ie. the side pane will never be displayed. Defaulttrue
.
property ionChange
ionChange: EventEmitter<SplitPane>;
{any} Expression to be called when the split-pane visibility has changed
property mainContent
mainContent: RootNode;
property sideContent
sideContent: RootNode;
property when
when: string | boolean;
{string | boolean} When the split-pane should be shown. Can be a CSS media query expression, or a shortcut expression. Can also be a boolean expression.
method initPane
initPane: () => boolean;
method isVisible
isVisible: () => boolean;
method ngAfterViewInit
ngAfterViewInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method setElementClass
setElementClass: (className: string, add: boolean) => void;
class Tab
class Tab extends NavControllerBase implements ITab {}
Tab The Tab component, written
<ion-tab>
, is styled based on the mode and should be used in conjunction with the [Tabs](../Tabs/) component.Each
ion-tab
is a declarative component for a [NavController](../../../navigation/NavController/). Basically, each tab is aNavController
. For more information on using navigation controllers take a look at the [NavController API Docs](../../../navigation/NavController/).See the [Tabs API Docs](../Tabs/) for more details on configuring Tabs.
To add a basic tab, you can use the following markup where the
root
property is the page you want to load for that tab,tabTitle
is the optional text to display on the tab, andtabIcon
is the optional [icon](../../icon/Icon/).<ion-tabs><ion-tab [root]="chatRoot" tabTitle="Chat" tabIcon="chat"></ion-tab></ion-tabs>Then, in your class you can set
chatRoot
to an imported class:import { ChatPage } from '../chat/chat';export class Tabs {// here we'll set the property of chatRoot to// the imported class of ChatPagechatRoot = ChatPage;constructor() {}}You can also pass some parameters to the root page of the tab through
rootParams
. Below we passchatParams
to the Chat tab:<ion-tabs><ion-tab [root]="chatRoot" [rootParams]="chatParams" tabTitle="Chat" tabIcon="chat"></ion-tab></ion-tabs>export class Tabs {chatRoot = ChatPage;// set some user information on chatParamschatParams = {user1: 'admin',user2: 'ionic'};constructor() {}}And in
ChatPage
you can get the data fromNavParams
:export class ChatPage {constructor(navParams: NavParams) {console.log('Passed params', navParams.data);}}Sometimes you may want to call a method instead of navigating to a new page. You can use the
(ionSelect)
event to call a method on your class when the tab is selected. Below is an example of presenting a modal from one of the tabs.<ion-tabs><ion-tab (ionSelect)="chat()" tabTitle="Show Modal"></ion-tab></ion-tabs>popexport class Tabs {constructor(public modalCtrl: ModalController) {}chat() {let modal = this.modalCtrl.create(ChatPage);modal.present();}}/docs/demos/src/tabs/
See Also
constructor
constructor( parent: Tabs, app: App, config: Config, plt: Platform, elementRef: ElementRef, zone: NgZone, renderer: Renderer, cfr: ComponentFactoryResolver, _cd: ChangeDetectorRef, gestureCtrl: GestureController, transCtrl: TransitionController, linker: DeepLinker, _dom: DomController, errHandler: ErrorHandler);
property btn
btn: TabButton;
property enabled
enabled: boolean;
{boolean} If true, enable the tab. If false, the user cannot interact with this element. Default:
true
.
property index
readonly index: number;
property ionSelect
ionSelect: EventEmitter<Tab>;
{Tab} Emitted when the current tab is selected.
property isSelected
isSelected: boolean;
property root
root: any;
{Page} Set the root page for this tab.
property rootParams
rootParams: any;
{object} Any nav-params to pass to the root page of this tab.
property show
show: boolean;
{boolean} If true, the tab button is visible within the tabbar. Default:
true
.
property tabBadge
tabBadge: string;
{string} The badge for the tab button.
property tabBadgeStyle
tabBadgeStyle: string;
{string} The badge color for the tab button.
property tabIcon
tabIcon: string;
{string} The icon for the tab button.
property tabsHideOnSubPages
tabsHideOnSubPages: boolean;
{boolean} If true, hide the tabs on child pages.
property tabTitle
tabTitle: string;
{string} The title of the tab button.
property tabUrlPath
tabUrlPath: string;
{string} The URL path name to represent this tab within the URL.
method getType
getType: () => string;
method goToRoot
goToRoot: (opts: NavOptions) => Promise<any>;
method load
load: (opts: NavOptions) => Promise<any>;
method ngOnDestroy
ngOnDestroy: () => void;
method ngOnInit
ngOnInit: () => void;
method resize
resize: () => void;
method setSelected
setSelected: (isSelected: boolean) => void;
method updateHref
updateHref: (component: any, data: any) => void;
class TabButton
class TabButton extends Ion implements OnInit {}
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
property disHover
disHover: boolean;
property hasBadge
hasBadge: boolean;
property hasIcon
hasIcon: boolean;
property hasIconOnly
hasIconOnly: boolean;
property hasTitle
hasTitle: boolean;
property hasTitleOnly
hasTitleOnly: boolean;
property ionSelect
ionSelect: EventEmitter<Tab>;
property layout
layout: string;
property tab
tab: Tab;
method ngOnInit
ngOnInit: () => void;
method onClick
onClick: () => boolean;
method updateHref
updateHref: (href: string) => void;
class TabHighlight
class TabHighlight {}
constructor
constructor(_elementRef: ElementRef, _dom: DomController);
method select
select: (tab: Tab) => void;
class Tabs
class Tabs extends Ion implements AfterViewInit, RootNode, ITabs, NavigationContainer {}
Tabs Tabs make it easy to navigate between different pages or functional aspects of an app. The Tabs component, written as
<ion-tabs>
, is a container of individual [Tab](../Tab/) components. Each individualion-tab
is a declarative component for a [NavController](../../../navigation/NavController/)For more information on using nav controllers like Tab or [Nav](../../nav/Nav/), take a look at the [NavController API Docs](../../../navigation/NavController/).
### Placement
The position of the tabs relative to the content varies based on the mode. The tabs are placed at the bottom of the screen for iOS and Android, and at the top for Windows by default. The position can be configured using the
tabsPlacement
attribute on the<ion-tabs>
component, or in an app's [config](../../config/Config/). See the [Input Properties](#input-properties) below for the available values oftabsPlacement
.### Layout
The layout for all of the tabs can be defined using the
tabsLayout
property. If the individual tab has a title and icon, the icons will show on top of the title by default. All tabs can be changed by setting the value oftabsLayout
on the<ion-tabs>
element, or in your app's [config](../../config/Config/). For example, this is useful if you want to show tabs with a title only on Android, but show icons and a title for iOS. See the [Input Properties](#input-properties) below for the available values oftabsLayout
.### Selecting a Tab
There are different ways you can select a specific tab from the tabs component. You can use the
selectedIndex
property to set the index on the<ion-tabs>
element, or you can callselect()
from theTabs
instance after creation. See [usage](#usage) below for more information.You can add a basic tabs template to a
@Component
using the following template:<ion-tabs><ion-tab [root]="tab1Root"></ion-tab><ion-tab [root]="tab2Root"></ion-tab><ion-tab [root]="tab3Root"></ion-tab></ion-tabs>Where
tab1Root
,tab2Root
, andtab3Root
are each a page:@Component({templateUrl: 'build/pages/tabs/tabs.html'})export class TabsPage {// this tells the tabs component which Pages// should be each tab's root Pagetab1Root = Page1;tab2Root = Page2;tab3Root = Page3;constructor() {}}By default, the first tab will be selected upon navigation to the Tabs page. We can change the selected tab by using
selectedIndex
on the<ion-tabs>
element:<ion-tabs selectedIndex="2"><ion-tab [root]="tab1Root"></ion-tab><ion-tab [root]="tab2Root"></ion-tab><ion-tab [root]="tab3Root"></ion-tab></ion-tabs>Since the index starts at
0
, this will select the 3rd tab which has root set totab3Root
. If you wanted to change it dynamically from your class, you could use [property binding](https://angular.io/docs/ts/latest/guide/template-syntax.html#!#property-binding).Alternatively, you can grab the
Tabs
instance and call theselect()
method. This requires the<ion-tabs>
element to have anid
. For example, set the value ofid
tomyTabs
:<ion-tabs #myTabs><ion-tab [root]="tab1Root"></ion-tab><ion-tab [root]="tab2Root"></ion-tab><ion-tab [root]="tab3Root"></ion-tab></ion-tabs>Then in your class you can grab the
Tabs
instance and callselect()
, passing the index of the tab as the argument. Here we're grabbing the tabs by using ViewChild.export class TabsPage {@ViewChild('myTabs') tabRef: Tabs;ionViewDidEnter() {this.tabRef.select(2);}}You can also switch tabs from a child component by calling
select()
on the parent view using theNavController
instance. For example, assuming you have aTabsPage
component, you could call the following from any of the child components to switch toTabsRoot3
:switchTabs() {this.navCtrl.parent.select(2);}/docs/demos/src/tabs/
See Also
constructor
constructor( parent: NavController, viewCtrl: ViewController, _app: App, config: Config, elementRef: ElementRef, _plt: Platform, renderer: Renderer, _linker: DeepLinker, keyboard?: Keyboard);
property ionChange
ionChange: EventEmitter<Tab>;
{any} Emitted when the tab changes.
property name
name: string;
{string} A unique name for the tabs
property parent
parent: NavControllerBase;
property selectedIndex
selectedIndex: number;
{number} The default selected tab index when first loaded. If a selected index isn't provided then it will use
0
, the first tab.
property tabsHighlight
tabsHighlight: boolean;
{boolean} If true, show the tab highlight bar under the selected tab.
property tabsLayout
tabsLayout: string;
{string} Set the tabbar layout:
icon-top
,icon-start
,icon-end
,icon-bottom
,icon-hide
,title-hide
.
property tabsPlacement
tabsPlacement: string;
{string} Set position of the tabbar:
top
,bottom
.
property viewCtrl
viewCtrl: ViewController;
method add
add: (tab: Tab) => string;
method getByIndex
getByIndex: (index: number) => Tab;
Parameter index
Index of the tab you want to get
Returns
{Tab} Returns the tab who's index matches the one passed
method getSecondaryIdentifier
getSecondaryIdentifier: () => string;
method getSelected
getSelected: () => Tab;
{Tab} Returns the currently selected tab
method getType
getType: () => string;
method goToRoot
goToRoot: (opts: NavOptions) => Promise<any>;
method previousTab
previousTab: (trimHistory?: boolean) => Tab;
Get the previously selected Tab which is currently not disabled or hidden.
Parameter trimHistory
If the selection history should be trimmed up to the previous tab selection or not.
Returns
{Tab}
method select
select: ( tabOrIndex: number | Tab, opts?: NavOptions, fromUrl?: boolean) => Promise<any>;
Parameter tabOrIndex
Index, or the Tab instance, of the tab to select.
class TapClick
class TapClick {}
constructor
constructor( config: Config, plt: Platform, dom: DomController, app: App, gestureCtrl: GestureController);
method click
click: (ev: any) => void;
method handleTapPolyfill
handleTapPolyfill: (ev: any) => void;
method isDisabledNativeClick
isDisabledNativeClick: () => boolean;
method pointerCancel
pointerCancel: (ev: UIEvent) => void;
method pointerEnd
pointerEnd: (ev: any, pointerEventType: number) => void;
method pointerMove
pointerMove: (ev: UIEvent) => void;
method pointerStart
pointerStart: (ev: any) => boolean;
method shouldCancelEvent
shouldCancelEvent: (ev: UIEvent) => boolean;
class TextInput
class TextInput extends BaseInput<string> implements IonicFormInput {}
Input
ion-input
is meant for text type inputs only, such astext
,password
,email
,number
,search
,tel
, andurl
. Ionic still uses an actual<input type="text">
HTML element within the component, however, with Ionic wrapping the native HTML input element it's better able to handle the user experience and interactivity.Similarly,
<ion-textarea>
should be used in place of<textarea>
.An
ion-input
is **not** used for non-text type inputs, such as acheckbox
,radio
,toggle
,range
,select
, etc.Along with the blur/focus events,
input
support all standard text input events likekeyup
,keydown
,keypress
,input
, etc. Any standard event can be attached and will function as expected. Example:<ion-input (click)="someFunction()"></ion-input>
<ion-list><ion-item><ion-label color="primary">Inline Label</ion-label><ion-input placeholder="Text Input"></ion-input></ion-item><ion-item><ion-label color="primary" fixed>Fixed Label</ion-label><ion-input type="tel" placeholder="Tel Input"></ion-input></ion-item><ion-item><ion-input type="number" placeholder="Number Input with no label"></ion-input></ion-item><ion-item><ion-label color="primary" stacked>Stacked Label</ion-label><ion-input type="email" placeholder="Email Input"></ion-input></ion-item><ion-item><ion-label color="primary" stacked>Stacked Label</ion-label><ion-input type="password" placeholder="Password Input"></ion-input></ion-item><ion-item><ion-label color="primary" floating>Floating Label</ion-label><ion-input></ion-input></ion-item><ion-item><ion-input placeholder="Clear Input" clearInput></ion-input></ion-item><ion-item><ion-textarea placeholder="Enter a description"></ion-textarea></ion-item></ion-list>/docs/demos/src/input/
constructor
constructor( config: Config, _plt: Platform, _form: Form, _app: App, elementRef: ElementRef, renderer: Renderer, _content: Content, _item: Item, ngControl: NgControl, _dom: DomController);
property autocomplete
autocomplete: string;
{string} Set the input's autocomplete property. Values:
"on"
,"off"
. Default"off"
.
property autocorrect
autocorrect: string;
{string} Set the input's autocorrect property. Values:
"on"
,"off"
. Default"off"
.
property blur
blur: EventEmitter<UIEvent>;
property clearInput
clearInput: any;
{boolean} If true, a clear icon will appear in the input when there is a value. Clicking it clears the input.
property clearOnEdit
clearOnEdit: any;
{boolean} If true, the value will be cleared after focus upon edit. Defaults to
true
whentype
is"password"
,false
for all other types.
property focus
focus: EventEmitter<UIEvent>;
property input
input: EventEmitter<UIEvent>;
property max
max: string | number;
{any} The maximum value, which must not be less than its minimum (min attribute) value.
property min
min: string | number;
{any} The minimum value, which must not be greater than its maximum (max attribute) value.
property ngControl
ngControl: NgControl;
property placeholder
placeholder: string;
{string} Instructional text that shows before the input has a value.
property readonly
readonly: boolean;
{boolean} If true, the user cannot modify the value.
property step
step: string | number;
{any} Works with the min and max attributes to limit the increments at which a value can be set.
property type
type: any;
{string} The type of control to display. The default type is text. Possible values are:
"text"
,"password"
,"email"
,"number"
,"search"
,"tel"
, or"url"
.
method checkClearOnEdit
checkClearOnEdit: (_: string) => void;
Check if we need to clear the text input if clearOnEdit is enabled
method clearTextInput
clearTextInput: () => void;
method initFocus
initFocus: () => void;
method ngAfterContentInit
ngAfterContentInit: () => void;
method ngAfterViewInit
ngAfterViewInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
method onBlur
onBlur: (ev: UIEvent) => void;
method onFocus
onFocus: (ev: UIEvent) => void;
method onInput
onInput: (ev: any) => void;
method onKeydown
onKeydown: (ev: any) => void;
method setBlur
setBlur: () => void;
method setFocus
setFocus: () => void;
class Thumbnail
class Thumbnail {}
Thumbnail ionic A Thumbnail is a component that creates a squared image for an item. Thumbnails can be place on the left or right side of an item with the
item-start
oritem-end
directive.See Also
class Toast
class Toast extends ViewController {}
constructor
constructor(app: App, opts: ToastOptions, config: Config);
method dismissAll
dismissAll: () => void;
Dismiss all toast components which have been presented.
method getTransitionName
getTransitionName: (direction: string) => string;
method isValidPosition
isValidPosition: (position: string) => boolean;
method present
present: (navOptions?: NavOptions) => Promise<any>;
Present the toast instance.
Parameter navOptions
Nav options to go with this transition.
Returns
{Promise} Returns a promise which is resolved when the transition has completed.
method setCssClass
setCssClass: (cssClass: string) => Toast;
Parameter cssClass
Toast message CSS class
method setDuration
setDuration: (dur: number) => Toast;
Parameter dur
Toast message duration
method setMessage
setMessage: (message: string) => Toast;
Parameter message
Toast message content
method setPosition
setPosition: (pos: 'top' | 'middle' | 'bottom') => Toast;
Parameter pos
Toast message position
method setShowCloseButton
setShowCloseButton: (closeButton: boolean) => Toast;
Parameter closeButton
Toast message close button
class ToastCmp
class ToastCmp implements AfterViewInit {}
constructor
constructor( _viewCtrl: ViewController, _config: Config, _elementRef: ElementRef, params: NavParams, renderer: Renderer);
property d
d: { message?: string; cssClass?: string; duration?: number; showCloseButton?: boolean; closeButtonText?: string; dismissOnPageChange?: boolean; position?: string;};
property descId
descId: string;
property dismissTimeout
dismissTimeout: number;
property enabled
enabled: boolean;
property hdrId
hdrId: string;
property id
id: number;
method cbClick
cbClick: () => void;
method dismiss
dismiss: (role: string) => Promise<any>;
method ionViewDidEnter
ionViewDidEnter: () => void;
method ngAfterViewInit
ngAfterViewInit: () => void;
class ToastController
class ToastController {}
ToastController A Toast is a subtle notification commonly used in modern applications. It can be used to provide feedback about an operation or to display a system message. The toast appears on top of the app's content, and can be dismissed by the app to resume user interaction with the app.
### Creating All of the toast options should be passed in the first argument of the create method:
create(opts)
. The message to display should be passed in themessage
property. TheshowCloseButton
option can be set to true in order to display a close button on the toast. See the [create](#create) method below for all available options.### Positioning Toasts can be positioned at the top, bottom or middle of the view port. The position can be passed to the
Toast.create(opts)
method. The position option is a string, and the values accepted aretop
,bottom
andmiddle
. If the position is not specified, the toast will be displayed at the bottom of the view port.### Dismissing The toast can be dismissed automatically after a specific amount of time by passing the number of milliseconds to display it in the
duration
of the toast options. IfshowCloseButton
is set to true, then the close button will dismiss the toast. To dismiss the toast after creation, call thedismiss()
method on the Toast instance. TheonDidDismiss
function can be called to perform an action after the toast is dismissed.import { ToastController } from 'ionic-angular';constructor(public toastCtrl: ToastController) { }presentToast() {const toast = this.toastCtrl.create({message: 'User was added successfully',duration: 3000,position: 'top'});toast.onDidDismiss(() => {console.log('Dismissed toast');});toast.present();}| Property | Type | Default | Description | |-----------------------|-----------|-----------------|---------------------------------------------------------------------------------------------------------------| | message |
string
| - | The message for the toast. Long strings will wrap and the toast container will expand. | | duration |number
| - | How many milliseconds to wait before hiding the toast. By default, it will show untildismiss()
is called. | | position |string
| "bottom" | The position of the toast on the screen. Accepted values: "top", "middle", "bottom". | | cssClass |string
| - | Additional classes for custom styles, separated by spaces. | | showCloseButton |boolean
| false | Whether or not to show a button to close the toast. | | closeButtonText |string
| "Close" | Text to display in the close button. | | dismissOnPageChange |boolean
| false | Whether to dismiss the toast when navigating to a new page. |/docs/demos/src/toast/
constructor
constructor(_app: App, config: Config);
property config
config: Config;
method create
create: (opts?: ToastOptions) => Toast;
Create a new toast component. See options below
Parameter opts
Toast options. See the below table for available options.
class Toggle
class Toggle extends BaseInput<boolean> implements IonicTapInput, AfterContentInit, OnDestroy {}
Toggle A toggle technically is the same thing as an HTML checkbox input, except it looks different and is easier to use on a touch device. Toggles can also have colors assigned to them, by adding any color attribute.
See the [Angular Docs](https://angular.io/docs/ts/latest/guide/forms) for more info on forms and inputs.
<ion-list><ion-item><ion-label>Pepperoni</ion-label><ion-toggle [(ngModel)]="pepperoni"></ion-toggle></ion-item><ion-item><ion-label>Sausage</ion-label><ion-toggle [(ngModel)]="sausage" disabled="true"></ion-toggle></ion-item><ion-item><ion-label>Mushrooms</ion-label><ion-toggle [(ngModel)]="mushrooms"></ion-toggle></ion-item></ion-list>/docs/demos/src/toggle/
See Also
constructor
constructor( form: Form, config: Config, _plt: Platform, elementRef: ElementRef, renderer: Renderer, _haptic: Haptic, item: Item, _gestureCtrl: GestureController, _domCtrl: DomController, _zone: NgZone);
property checked
checked: boolean;
{boolean} If true, the element is selected.
method ngAfterContentInit
ngAfterContentInit: () => void;
method ngOnDestroy
ngOnDestroy: () => void;
class Toolbar
class Toolbar extends ToolbarBase {}
Toolbar A Toolbar is a generic bar that is positioned above or below content. Unlike a [Navbar](../Navbar/), a toolbar can be used as a subheader. When toolbars are placed within an
<ion-header>
or<ion-footer>
, the toolbars stay fixed in their respective location. When placed within<ion-content>
, toolbars will scroll with the content.### Buttons in a Toolbar Buttons placed in a toolbar should be placed inside of the
<ion-buttons>
element. An exception to this is a [menuToggle](../../menu/MenuToggle) button. It should not be placed inside of the<ion-buttons>
element. Both the<ion-buttons>
element and themenuToggle
can be positioned inside of the toolbar using different properties. The below chart has a description of each property.| Property | Description | |-------------|-----------------------------------------------------------------------------------------------------------------------| |
start
| Positions element to the left of the content inios
mode, and directly to the right inmd
andwp
mode. | |end
| Positions element to the right of the content inios
mode, and to the far right inmd
andwp
mode. | |left
| Positions element to the left of all other elements. | |right
| Positions element to the right of all other elements. |### Header / Footer Box Shadow and Border In
md
mode, the<ion-header>
will receive a box-shadow on the bottom, and the<ion-footer>
will receive a box-shadow on the top. Inios
mode, the<ion-header>
will receive a border on the bottom, and the<ion-footer>
will receive a border on the top. Both themd
box-shadow and theios
border can be removed by adding theno-border
attribute to the element.<ion-header no-border><ion-toolbar><ion-title>Header</ion-title></ion-toolbar></ion-header><ion-content></ion-content><ion-footer no-border><ion-toolbar><ion-title>Footer</ion-title></ion-toolbar></ion-footer><ion-header no-border><ion-toolbar><ion-title>My Toolbar Title</ion-title></ion-toolbar><ion-toolbar><ion-title>I'm a subheader</ion-title></ion-toolbar><ion-header><ion-content><ion-toolbar><ion-title>Scrolls with the content</ion-title></ion-toolbar></ion-content><ion-footer no-border><ion-toolbar><ion-title>I'm a footer</ion-title></ion-toolbar></ion-footer>/docs/demos/src/toolbar/
See Also
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class ToolbarItem
class ToolbarItem extends Ion {}
constructor
constructor( config: Config, elementRef: ElementRef, renderer: Renderer, toolbar: Toolbar, navbar: Navbar);
property inToolbar
inToolbar: boolean;
class ToolbarTitle
class ToolbarTitle extends Ion {}
Title
ion-title
is a component that sets the title of theToolbar
orNavbar
<ion-header><ion-navbar><ion-title>Settings</ion-title></ion-navbar></ion-header>Or to create a navbar with a toolbar as a subheader:
<ion-header><ion-navbar><ion-title>Main Header</ion-title></ion-navbar><ion-toolbar><ion-title>Subheader</ion-title></ion-toolbar></ion-header>/docs/demos/src/title/
constructor
constructor( config: Config, elementRef: ElementRef, renderer: Renderer, toolbar: Toolbar, navbar: Navbar);
method getTitleText
getTitleText: () => any;
class Transition
class Transition extends Animation {}
- play - Add before classes - DOM WRITE - Remove before classes - DOM WRITE - Add before inline styles - DOM WRITE - set inline FROM styles - DOM WRITE - RAF - read toolbar dimensions - DOM READ - write content top/bottom padding - DOM WRITE - set css transition duration/easing - DOM WRITE - RAF - set inline TO styles - DOM WRITE
constructor
constructor( plt: Platform, enteringView: ViewController, leavingView: ViewController, opts: AnimationOptions);
property enteringView
enteringView: ViewController;
property leavingView
leavingView: ViewController;
property parent
parent: Transition;
property trnsId
trnsId: number;
method destroy
destroy: () => void;
method init
init: () => void;
method registerStart
registerStart: (trnsStart: Function) => void;
method start
start: () => void;
class Typography
class Typography extends Ion {}
Typography ionic
The Typography component is a simple component that can be used to style the text color of any element. The
ion-text
attribute should be added to the element in order to pass a color from the Sass$colors
map and change the text color of that element.<h1 ion-text color="secondary">H1: The quick brown fox jumps over the lazy dog</h1><h2 ion-text color="primary">H2: The quick brown fox jumps over the lazy dog</h2><h3 ion-text color="light">H3: The quick brown fox jumps over the lazy dog</h3><h4 ion-text color="danger">H4: The quick brown fox jumps over the lazy dog</h4><h5 ion-text color="dark">H5: The quick brown fox jumps over the lazy dog</h5><h6 ion-text [color]="dynamicColor">H6: The quick brown fox jumps over the lazy dog</h6><p>I saw a werewolf with a Chinese menu in his hand.Walking through the <sub ion-text color="danger">streets</sub> of Soho in the rain.He <i ion-text color="primary">was</i> looking for a place called Lee Ho Fook's.Gonna get a <a ion-text color="secondary">big dish of beef chow mein.</a></p><p>He's the hairy-handed gent who ran amuck in Kent.Lately he's <sup ion-text color="primary">been</sup> overheard in Mayfair.Better stay away from him.He'll rip your lungs out, Jim.I'd like to meet his tailor.</p>
constructor
constructor(config: Config, elementRef: ElementRef, renderer: Renderer);
class UrlSerializer
class UrlSerializer {}
constructor
constructor(_app: App, config: DeepLinkConfig);
property links
links: NavLink[];
method createSegmentFromName
createSegmentFromName: ( navContainer: NavigationContainer, nameOrComponent: any) => NavSegment;
method getLinkFromName
getLinkFromName: (nameOrComponent: any) => NavLink;
method parse
parse: (browserUrl: string) => NavSegment[];
Parse the URL into a Path, which is made up of multiple NavSegments. Match which components belong to each segment.
method serialize
serialize: (segments: NavSegment[]) => string;
Serialize a path, which is made up of multiple NavSegments, into a URL string. Turn each segment into a string and concat them to a URL.
method serializeComponent
serializeComponent: ( navContainer: NavigationContainer, component: any, data: any) => NavSegment;
Serializes a component and its data into a NavSegment.
class ViewController
class ViewController {}
ViewController Access various features and information about the current view. ```ts import { Component } from '@angular/core'; import { ViewController } from 'ionic-angular';
@Component({...}) export class MyPage{
constructor(public viewCtrl: ViewController) {}
} ```
constructor
constructor(component?: any, data?: any, rootCssClass?: string);
property component
component: any;
property data
data: any;
property didEnter
didEnter: EventEmitter<any>;
Observable to be subscribed to when the current component has become active
Returns
{Observable} Returns an observable
property didLeave
didLeave: EventEmitter<any>;
Observable to be subscribed to when the current component is no long active
Returns
{Observable} Returns an observable
property id
id: string;
property index
readonly index: number;
Get the index of the current component in the current navigation stack.
Returns
{number} Returns the index of this page within its
NavController
.
property instance
instance: any;
property isOverlay
isOverlay: boolean;
property name
readonly name: string;
property readReady
readReady: EventEmitter<any>;
property willEnter
willEnter: EventEmitter<any>;
Observable to be subscribed to when the current component will become active
Returns
{Observable} Returns an observable
property willLeave
willLeave: EventEmitter<any>;
Observable to be subscribed to when the current component will no longer be active
Returns
{Observable} Returns an observable
property willUnload
willUnload: EventEmitter<any>;
Observable to be subscribed to when the current component has been destroyed
Returns
{Observable} Returns an observable
property writeReady
writeReady: EventEmitter<any>;
method contentRef
contentRef: () => ElementRef;
Returns
{ElementRef} Returns the Content's ElementRef.
method dismiss
dismiss: (data?: any, role?: string, navOptions?: NavOptions) => Promise<any>;
Dismiss the current viewController
Parameter data
Data that you want to return when the viewController is dismissed.
Parameter role
Parameter navOptions
Options for the dismiss navigation.
Returns
{any} data Returns the data passed in, if any.
method emit
emit: (data?: any) => void;
method enableBack
enableBack: () => boolean;
Check to see if you can go back in the navigation stack.
Returns
{boolean} Returns if it's possible to go back from this Page.
method getContent
getContent: () => any;
Returns
{component} Returns the Page's Content component reference.
method getFooter
getFooter: () => Footer;
method getHeader
getHeader: () => Header;
method getIONContent
getIONContent: () => Content;
method getIONContentRef
getIONContentRef: () => ElementRef;
method getNav
getNav: () => NavController;
method getNavbar
getNavbar: () => Navbar;
method getNavParams
getNavParams: () => NavParams;
method getTransitionName
getTransitionName: (_direction: string) => string;
method getZIndex
getZIndex: () => number;
method handleOrientationChange
handleOrientationChange: () => void;
method hasNavbar
hasNavbar: () => boolean;
Find out if the current component has a NavBar or not. Be sure to wrap this in an
ionViewWillEnter
method in order to make sure the view has rendered fully.Returns
{boolean} Returns a boolean if this Page has a navbar or not.
method init
init: (componentRef: ComponentRef<any>) => void;
method isFirst
isFirst: () => boolean;
Returns
{boolean} Returns if this Page is the first in the stack of pages within its NavController.
method isLast
isLast: () => boolean;
Returns
{boolean} Returns if this Page is the last in the stack of pages within its NavController.
method onDidDismiss
onDidDismiss: (callback: (data: any, role: string) => void) => void;
Called when the current viewController has be successfully dismissed
method onWillDismiss
onWillDismiss: (callback: (data: any, role: string) => void) => void;
Called when the current viewController will be dismissed
method pageRef
pageRef: () => ElementRef;
Returns
{ElementRef} Returns the Page's ElementRef.
method setBackButtonText
setBackButtonText: (val: string) => void;
Change the title of the back-button. Be sure to call this after
ionViewWillEnter
to make sure the DOM has been rendered.Parameter val
Set the back button text.
method setLeavingOpts
setLeavingOpts: (opts: NavOptions) => void;
method showBackButton
showBackButton: (shouldShow: boolean) => void;
Set if the back button for the current view is visible or not. Be sure to call this after
ionViewWillEnter
to make sure the DOM has been rendered.Parameter Set
if this Page's back button should show or not.
method subscribe
subscribe: (generatorOrNext?: any) => any;
class VirtualFooter
class VirtualFooter {}
constructor
constructor(templateRef: TemplateRef<VirtualContext>);
property templateRef
templateRef: TemplateRef<VirtualContext>;
class VirtualHeader
class VirtualHeader {}
constructor
constructor(templateRef: TemplateRef<VirtualContext>);
property templateRef
templateRef: TemplateRef<VirtualContext>;
class VirtualItem
class VirtualItem {}
constructor
constructor( templateRef: TemplateRef<VirtualContext>, viewContainer: ViewContainerRef);
property templateRef
templateRef: TemplateRef<VirtualContext>;
property viewContainer
viewContainer: ViewContainerRef;
class VirtualScroll
class VirtualScroll implements DoCheck, OnChanges, AfterContentInit, OnDestroy {}
VirtualScroll Virtual Scroll displays a virtual, "infinite" list. An array of records is passed to the virtual scroll containing the data to create templates for. The template created for each record, referred to as a cell, can consist of items, headers, and footers.
For performance reasons, not every record in the list is rendered at once; instead a small subset of records (enough to fill the viewport) are rendered and reused as the user scrolls.
### The Basics
The array of records should be passed to the
virtualScroll
property. The data given to thevirtualScroll
property must be an array. An item template with the*virtualItem
property is required in thevirtualScroll
. ThevirtualScroll
and*virtualItem
properties can be added to any element.<ion-list [virtualScroll]="items"><ion-item *virtualItem="let item">{% raw %}{{ item }}{% endraw %}</ion-item></ion-list>### Section Headers and Footers
Section headers and footers are optional. They can be dynamically created from developer-defined functions. For example, a large list of contacts usually has a divider for each letter in the alphabet. Developers provide their own custom function to be called on each record. The logic in the custom function should determine whether to create the section template and what data to provide to the template. The custom function should return
null
if a template shouldn't be created.<ion-list [virtualScroll]="items" [headerFn]="myHeaderFn"><ion-item-divider *virtualHeader="let header">Header: {% raw %}{{ header }}{% endraw %}</ion-item-divider><ion-item *virtualItem="let item">Item: {% raw %}{{ item }}{% endraw %}</ion-item></ion-list>Below is an example of a custom function called on every record. It gets passed the individual record, the record's index number, and the entire array of records. In this example, after every 20 records a header will be inserted. So between the 19th and 20th records, between the 39th and 40th, and so on, a
<ion-item-divider>
will be created and the template's data will come from the function's returned data.myHeaderFn(record, recordIndex, records) {if (recordIndex % 20 === 0) {return 'Header ' + recordIndex;}return null;}### Approximate Widths and Heights
If the height of items in the virtual scroll are not close to the default size of 40px, it is extremely important to provide a value for approxItemHeight height. An exact pixel-perfect size is not necessary, but without an estimate the virtual scroll will not render correctly.
The approximate width and height of each template is used to help determine how many cells should be created, and to help calculate the height of the scrollable area. Note that the actual rendered size of each cell comes from the app's CSS, whereas this approximation is only used to help calculate initial dimensions.
It's also important to know that Ionic's default item sizes have slightly different heights between platforms, which is perfectly fine.
### Images Within Virtual Scroll
HTTP requests, image decoding, and image rendering can cause jank while scrolling. In order to better control images, Ionic provides
<ion-img>
to manage HTTP requests and image rendering. While scrolling through items quickly,<ion-img>
knows when and when not to make requests, when and when not to render images, and only loads the images that are viewable after scrolling. [Read more aboution-img
.](../../img/Img/)It's also important for app developers to ensure image sizes are locked in, and after images have fully loaded they do not change size and affect any other element sizes. Simply put, to ensure rendering bugs are not introduced, it's vital that elements within a virtual item does not dynamically change.
For virtual scrolling, the natural effects of the
<img>
are not desirable features. We recommend using the<ion-img>
component over the native<img>
element because when an<img>
element is added to the DOM, it immediately makes a HTTP request for the image file. Additionally,<img>
renders whenever it wants which could be while the user is scrolling. However,<ion-img>
is governed by the containingion-content
and does not render images while scrolling quickly.<ion-list [virtualScroll]="items"><ion-item *virtualItem="let item"><ion-avatar item-start><ion-img [src]="item.avatarUrl"></ion-img></ion-avatar>{% raw %} {{ item.firstName }} {{ item.lastName }}{% endraw %}</ion-item></ion-list>### Custom Components
If a custom component is going to be used within Virtual Scroll, it's best to wrap it with a good old
<div>
to ensure the component is rendered correctly. Since each custom component's implementation and internals can be quite different, wrapping within a<div>
is a safe way to make sure dimensions are measured correctly.<ion-list [virtualScroll]="items"><div *virtualItem="let item"><my-custom-item [item]="item">{% raw %} {{ item }}{% endraw %}</my-custom-item></div></ion-list>## Virtual Scroll Performance Tips
#### iOS Cordova WKWebView
When deploying to iOS with Cordova, it's highly recommended to use the [WKWebView plugin](http://blog.ionic.io/cordova-ios-performance-improvements-drop-in-speed-with-wkwebview/) in order to take advantage of iOS's higher performimg webview. Additionally, WKWebView is superior at scrolling efficiently in comparision to the older UIWebView.
#### Lock in element dimensions and locations
In order for virtual scroll to efficiently size and locate every item, it's very important every element within each virtual item does not dynamically change its dimensions or location. The best way to ensure size and location does not change, it's recommended each virtual item has locked in its size via CSS.
#### Use
ion-img
for imagesWhen including images within Virtual Scroll, be sure to use [
ion-img
](../img/Img/) rather than the standard<img>
HTML element. Withion-img
, images are lazy loaded so only the viewable ones are rendered, and HTTP requests are efficiently controlled while scrolling.#### Set Approximate Widths and Heights
As mentioned above, all elements should lock in their dimensions. However, virtual scroll isn't aware of the dimensions until after they have been rendered. For the initial render, virtual scroll still needs to set how many items should be built. With "approx" property inputs, such as
approxItemHeight
, we're able to give virtual scroll an approximate size, therefore allowing virtual scroll to decide how many items should be created.#### Changing dataset should use
virtualTrackBy
It is possible for the identities of elements in the iterator to change while the data does not. This can happen, for example, if the iterator produced from an RPC to the server, and that RPC is re-run. Even if the "data" hasn't changed, the second response will produce objects with different identities, and Ionic will tear down the entire DOM and rebuild it. This is an expensive operation and should be avoided if possible.
#### Efficient headers and footer functions
Each virtual item must stay extremely efficient, but one way to really kill its performance is to perform any DOM operations within section header and footer functions. These functions are called for every record in the dataset, so please make sure they're performant.
constructor
constructor( _iterableDiffers: IterableDiffers, _elementRef: ElementRef, _renderer: Renderer, _zone: NgZone, _cd: ChangeDetectorRef, _content: Content, _plt: Platform, _ctrl: ViewController, _config: Config, _dom: DomController);
property approxFooterHeight
approxFooterHeight: string;
{string} The approximate height of each footer template's cell. This dimension is used to help determine how many cells should be created when initialized, and to help calculate the height of the scrollable area. This height value can only use
px
units. Note that the actual rendered size of each cell comes from the app's CSS, whereas this approximation is used to help calculate initial dimensions before the item has been rendered. Default is40px
.
property approxFooterWidth
approxFooterWidth: string;
{string} The approximate width of each footer template's cell. This dimension is used to help determine how many cells should be created when initialized, and to help calculate the height of the scrollable area. This value can use either
px
or%
units. Note that the actual rendered size of each cell comes from the app's CSS, whereas this approximation is used to help calculate initial dimensions before the item has been rendered. Default is100%
.
property approxHeaderHeight
approxHeaderHeight: string;
{string} The approximate height of each header template's cell. This dimension is used to help determine how many cells should be created when initialized, and to help calculate the height of the scrollable area. This height value can only use
px
units. Note that the actual rendered size of each cell comes from the app's CSS, whereas this approximation is used to help calculate initial dimensions before the item has been rendered. Default is40px
.
property approxHeaderWidth
approxHeaderWidth: string;
{string} The approximate width of each header template's cell. This dimension is used to help determine how many cells should be created when initialized, and to help calculate the height of the scrollable area. This value can use either
px
or%
units. Note that the actual rendered size of each cell comes from the app's CSS, whereas this approximation is used to help calculate initial dimensions. Default is100%
.
property approxItemHeight
approxItemHeight: string;
{string} It is important to provide this if virtual item height will be significantly larger than the default The approximate height of each virtual item template's cell. This dimension is used to help determine how many cells should be created when initialized, and to help calculate the height of the scrollable area. This height value can only use
px
units. Note that the actual rendered size of each cell comes from the app's CSS, whereas this approximation is used to help calculate initial dimensions before the item has been rendered. Default is40px
.
property approxItemWidth
approxItemWidth: string;
{string} The approximate width of each item template's cell. This dimension is used to help determine how many cells should be created when initialized, and to help calculate the height of the scrollable area. This value can use either
px
or%
units. Note that the actual rendered size of each cell comes from the app's CSS, whereas this approximation is used to help calculate initial dimensions before the item has been rendered. Default is100%
.
property bufferRatio
bufferRatio: number;
{number} The buffer ratio is used to decide how many cells should get created when initially rendered. The number is a multiplier against the viewable area's height. For example, if it takes
20
cells to fill up the height of the viewable area, then with a buffer ratio of3
it will create60
cells that are available for reuse while scrolling. For better performance, it's better to have more cells than what are required to fill the viewable area. Default is3
. In case more than one items are rendered per row, bufferRatio has to account for that and a multiple number should be used. For example if a single item per row list used 3 as bufferRatio a 4 item per row list should use 3 * 4 = 12 as buffer ratio.
property footerFn
footerFn: Function;
{function} Section footers and the data used within its given template can be dynamically created by passing a function to
footerFn
. The logic within the footer function can decide if the footer template should be used, and what data to give to the footer template. The function must returnnull
if a footer cell shouldn't be created.
property headerFn
headerFn: Function;
{function} Section headers and the data used within its given template can be dynamically created by passing a function to
headerFn
. For example, a large list of contacts usually has dividers between each letter in the alphabet. App's can provide their own customheaderFn
which is called with each record within the dataset. The logic within the header function can decide if the header template should be used, and what data to give to the header template. The function must returnnull
if a header cell shouldn't be created.
property virtualScroll
virtualScroll: any;
{array} The data that builds the templates within the virtual scroll. This is the same data that you'd pass to
*ngFor
. It's important to note that when this data has changed, then the entire virtual scroll is reset, which is an expensive operation and should be avoided if possible.
property virtualTrackBy
virtualTrackBy: TrackByFunction<any>;
{function} Same as
ngForTrackBy
which can be used onngFor
.
method firstRecord
firstRecord: () => number;
method lastRecord
lastRecord: () => number;
method ngAfterContentInit
ngAfterContentInit: () => void;
method ngDoCheck
ngDoCheck: () => void;
method ngOnChanges
ngOnChanges: (changes: SimpleChanges) => void;
method ngOnDestroy
ngOnDestroy: () => void;
method readUpdate
readUpdate: (needClean: boolean) => void;
method renderVirtual
renderVirtual: (needClean: boolean) => void;
DOM WRITE
method resize
resize: () => void;
method scrollEnd
scrollEnd: () => void;
DOM WRITE
method scrollUpdate
scrollUpdate: (ev: ScrollEvent) => void;
method setElementClass
setElementClass: (className: string, add: boolean) => void;
method writeUpdate
writeUpdate: (needClean: boolean) => void;
Interfaces
interface ActionSheetButton
interface ActionSheetButton {}
interface ActionSheetOptions
interface ActionSheetOptions {}
property buttons
buttons?: (ActionSheetButton | string)[];
property cssClass
cssClass?: string;
property enableBackdropDismiss
enableBackdropDismiss?: boolean;
property subTitle
subTitle?: string;
property title
title?: string;
interface AlertButton
interface AlertButton {}
interface AlertOptions
interface AlertOptions {}
property buttons
buttons?: (AlertButton | string)[];
property cssClass
cssClass?: string;
property enableBackdropDismiss
enableBackdropDismiss?: boolean;
property inputs
inputs?: AlertInputOptions[];
property message
message?: string;
property mode
mode?: string;
property subTitle
subTitle?: string;
property title
title?: string;
interface AnimationOptions
interface AnimationOptions {}
interface BlockerOptions
interface BlockerOptions {}
property disable
disable?: string[];
property disableScroll
disableScroll?: boolean;
interface DeepLinkConfig
interface DeepLinkConfig {}
property links
links: DeepLinkMetadata[];
interface DeepLinkMetadataFactory
interface DeepLinkMetadataFactory {}
construct signature
new (obj: IonicPageMetadata): DeepLinkMetadata;
call signature
(obj: IonicPageMetadata): DeepLinkDecorator;
interface EffectProperty
interface EffectProperty {}
interface EffectState
interface EffectState {}
interface GestureOptions
interface GestureOptions {}
property disableScroll
disableScroll?: boolean;
property name
name: string;
property priority
priority?: number;
interface IonicPageMetadata
interface IonicPageMetadata {}
public link interface
property defaultHistory
defaultHistory?: string[];
property name
name?: string;
property priority
priority?: string;
property segment
segment?: string;
interface LoadingOptions
interface LoadingOptions {}
property content
content?: string;
property cssClass
cssClass?: string;
property dismissOnPageChange
dismissOnPageChange?: boolean;
property duration
duration?: number;
property enableBackdropDismiss
enableBackdropDismiss?: boolean;
property showBackdrop
showBackdrop?: boolean;
property spinner
spinner?: string;
interface ModalOptions
interface ModalOptions {}
property cssClass
cssClass?: string;
property enableBackdropDismiss
enableBackdropDismiss?: boolean;
property enterAnimation
enterAnimation?: string;
property leaveAnimation
leaveAnimation?: string;
property showBackdrop
showBackdrop?: boolean;
interface NavLink
interface NavLink {}
property component
component?: any;
property dataKeys
dataKeys?: { [key: string]: boolean;};
property dataLen
dataLen?: number;
property defaultHistory
defaultHistory?: any[];
property loadChildren
loadChildren?: string;
property name
name?: string;
property segment
segment?: string;
property segmentParts
segmentParts?: string[];
property segmentPartsLen
segmentPartsLen?: number;
property staticLen
staticLen?: number;
interface NavOptions
interface NavOptions {}
property animate
animate?: boolean;
property animation
animation?: string;
property direction
direction?: string;
property disableApp
disableApp?: boolean;
property duration
duration?: number;
property easing
easing?: string;
property ev
ev?: any;
property id
id?: string;
property isNavRoot
isNavRoot?: boolean;
property keyboardClose
keyboardClose?: boolean;
property minClickBlockDuration
minClickBlockDuration?: number;
property progressAnimation
progressAnimation?: boolean;
property updateUrl
updateUrl?: boolean;
interface PanGestureConfig
interface PanGestureConfig {}
property capture
capture?: boolean;
property direction
direction?: 'x' | 'y';
property domController
domController?: DomController;
property gesture
gesture?: GestureDelegate;
property maxAngle
maxAngle?: number;
property passive
passive?: boolean;
property threshold
threshold?: number;
property zone
zone?: boolean;
interface PickerColumn
interface PickerColumn {}
property align
align?: string;
property columnWidth
columnWidth?: string;
property cssClass
cssClass?: string;
property mode
mode?: string;
property name
name?: string;
property options
options?: PickerColumnOption[];
property optionsWidth
optionsWidth?: string;
property prefix
prefix?: string;
property prefixWidth
prefixWidth?: string;
property prevSelected
prevSelected?: number;
property selectedIndex
selectedIndex?: number;
property suffix
suffix?: string;
property suffixWidth
suffixWidth?: string;
interface PickerColumnOption
interface PickerColumnOption {}
interface PickerOptions
interface PickerOptions {}
property buttons
buttons?: any[];
property columns
columns?: PickerColumn[];
property cssClass
cssClass?: string;
property enableBackdropDismiss
enableBackdropDismiss?: boolean;
property mode
mode?: string;
interface PlayOptions
interface PlayOptions {}
property duration
duration?: number;
interface PopoverOptions
interface PopoverOptions {}
property cssClass
cssClass?: string;
property enableBackdropDismiss
enableBackdropDismiss?: boolean;
property showBackdrop
showBackdrop?: boolean;
interface ScrollEvent
interface ScrollEvent {}
property contentBottom
contentBottom: number;
property contentElement
contentElement?: HTMLElement;
property contentHeight
contentHeight: number;
property contentTop
contentTop: number;
property contentWidth
contentWidth: number;
property deltaX
deltaX: number;
property deltaY
deltaY: number;
property directionX
directionX: string;
property directionY
directionY: string;
property domWrite
domWrite: { (fn: DomCallback, ctx?: any): void;};
property fixedElement
fixedElement?: HTMLElement;
property footerElement
footerElement?: HTMLElement;
property headerElement
headerElement?: HTMLElement;
property scrollElement
scrollElement?: HTMLElement;
property scrollHeight
scrollHeight: number;
property scrollLeft
scrollLeft: number;
property scrollTop
scrollTop: number;
property scrollWidth
scrollWidth: number;
property startX
startX: number;
property startY
startY: number;
property timeStamp
timeStamp: number;
property velocityX
velocityX: number;
property velocityY
velocityY: number;
interface SelectPopoverOption
interface SelectPopoverOption {}
interface SlideData
interface SlideData {}
property delta
delta: number;
property distance
distance: number;
property elementStartPos
elementStartPos: number;
property max
max: number;
property min
min: number;
property pointerStartPos
pointerStartPos: number;
property pos
pos: any;
property started
started: boolean;
property timestamp
timestamp: number;
property velocity
velocity: number;
interface ToastOptions
interface ToastOptions {}
property closeButtonText
closeButtonText?: string;
property cssClass
cssClass?: string;
property dismissOnPageChange
dismissOnPageChange?: boolean;
property duration
duration?: number;
property message
message?: string;
property position
position?: string;
property showCloseButton
showCloseButton?: boolean;
Type Aliases
type DomCallback
type DomCallback = { (timeStamp?: number): void;};
Package Files (146)
- animations/animation.d.ts
- components/action-sheet/action-sheet-component.d.ts
- components/action-sheet/action-sheet-controller.d.ts
- components/action-sheet/action-sheet-options.d.ts
- components/action-sheet/action-sheet.d.ts
- components/alert/alert-component.d.ts
- components/alert/alert-controller.d.ts
- components/alert/alert-options.d.ts
- components/alert/alert.d.ts
- components/app/app-root.d.ts
- components/app/app.d.ts
- components/app/menu-controller.d.ts
- components/avatar/avatar.d.ts
- components/backdrop/backdrop.d.ts
- components/badge/badge.d.ts
- components/button/button.d.ts
- components/card/card-content.d.ts
- components/card/card-header.d.ts
- components/card/card-title.d.ts
- components/card/card.d.ts
- components/checkbox/checkbox.d.ts
- components/chip/chip.d.ts
- components/content/content.d.ts
- components/datetime/datetime.d.ts
- components/fab/fab-container.d.ts
- components/fab/fab-list.d.ts
- components/fab/fab.d.ts
- components/grid/col.d.ts
- components/grid/grid.d.ts
- components/grid/row.d.ts
- components/icon/icon.d.ts
- components/img/img.d.ts
- components/infinite-scroll/infinite-scroll-content.d.ts
- components/infinite-scroll/infinite-scroll.d.ts
- components/input/input.d.ts
- components/ion.d.ts
- components/item/item-content.d.ts
- components/item/item-divider.d.ts
- components/item/item-group.d.ts
- components/item/item-options.d.ts
- components/item/item-reorder.d.ts
- components/item/item-sliding.d.ts
- components/item/item.d.ts
- components/item/reorder.d.ts
- components/label/label.d.ts
- components/list/list-header.d.ts
- components/list/list.d.ts
- components/loading/loading-component.d.ts
- components/loading/loading-controller.d.ts
- components/loading/loading-options.d.ts
- components/loading/loading.d.ts
- components/menu/menu-close.d.ts
- components/menu/menu-toggle.d.ts
- components/menu/menu-types.d.ts
- components/menu/menu.d.ts
- components/modal/modal-component.d.ts
- components/modal/modal-controller.d.ts
- components/modal/modal-options.d.ts
- components/modal/modal.d.ts
- components/nav/nav-pop-anchor.d.ts
- components/nav/nav-pop.d.ts
- components/nav/nav-push-anchor.d.ts
- components/nav/nav-push.d.ts
- components/nav/nav.d.ts
- components/note/note.d.ts
- components/option/option.d.ts
- components/picker/picker-column.d.ts
- components/picker/picker-component.d.ts
- components/picker/picker-controller.d.ts
- components/picker/picker-options.d.ts
- components/picker/picker.d.ts
- components/popover/popover-component.d.ts
- components/popover/popover-controller.d.ts
- components/popover/popover-options.d.ts
- components/popover/popover.d.ts
- components/radio/radio-button.d.ts
- components/radio/radio-group.d.ts
- components/range/range-knob.d.ts
- components/range/range.d.ts
- components/refresher/refresher-content.d.ts
- components/refresher/refresher.d.ts
- components/scroll/scroll.d.ts
- components/searchbar/searchbar.d.ts
- components/segment/segment-button.d.ts
- components/segment/segment.d.ts
- components/select/select-popover-component.d.ts
- components/select/select.d.ts
- components/show-hide-when/display-when.d.ts
- components/show-hide-when/hide-when.d.ts
- components/show-hide-when/show-when.d.ts
- components/slides/slide.d.ts
- components/slides/slides.d.ts
- components/spinner/spinner.d.ts
- components/split-pane/split-pane.d.ts
- components/tabs/tab-button.d.ts
- components/tabs/tab-highlight.d.ts
- components/tabs/tab.d.ts
- components/tabs/tabs.d.ts
- components/thumbnail/thumbnail.d.ts
- components/toast/toast-component.d.ts
- components/toast/toast-controller.d.ts
- components/toast/toast-options.d.ts
- components/toast/toast.d.ts
- components/toggle/toggle.d.ts
- components/toolbar/navbar.d.ts
- components/toolbar/toolbar-footer.d.ts
- components/toolbar/toolbar-header.d.ts
- components/toolbar/toolbar-item.d.ts
- components/toolbar/toolbar-title.d.ts
- components/toolbar/toolbar.d.ts
- components/typography/typography.d.ts
- components/virtual-scroll/virtual-footer.d.ts
- components/virtual-scroll/virtual-header.d.ts
- components/virtual-scroll/virtual-item.d.ts
- components/virtual-scroll/virtual-scroll.d.ts
- config/config.d.ts
- config/mode-registry.d.ts
- gestures/gesture-config.d.ts
- gestures/gesture-controller.d.ts
- gestures/gesture.d.ts
- gestures/pan-gesture.d.ts
- gestures/slide-edge-gesture.d.ts
- gestures/slide-gesture.d.ts
- index.d.ts
- module.d.ts
- navigation/deep-linker.d.ts
- navigation/ionic-page.d.ts
- navigation/nav-controller-base.d.ts
- navigation/nav-controller.d.ts
- navigation/nav-params.d.ts
- navigation/nav-util.d.ts
- navigation/url-serializer.d.ts
- navigation/view-controller.d.ts
- platform/dom-controller.d.ts
- platform/keyboard.d.ts
- platform/platform-registry.d.ts
- platform/platform.d.ts
- tap-click/haptic.d.ts
- tap-click/tap-click.d.ts
- transitions/page-transition.d.ts
- transitions/transition.d.ts
- util/events.d.ts
- util/form.d.ts
- util/ionic-error-handler.d.ts
- util/scroll-view.d.ts
- util/util.d.ts
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ionic-angular
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ionic-angular)
- HTML<a href="https://www.jsdocs.io/package/ionic-angular"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 13553 ms. - Missing or incorrect documentation? Open an issue for this package.