Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

ViewController

Improve this doc

Access various features and information about the current view.

Usage

import { Component } from '@angular/core';
import { ViewController } from 'ionic-angular';

@Component({...})
export class MyPage{

  constructor(public viewCtrl: ViewController) {}

}

Instance Members

component

contentRef()

Returns: ElementRef

Returns the Content's ElementRef.

didEnter

Observable to be subscribed to when the current component has become active

Returns: Observable

Returns an observable

didLeave

Observable to be subscribed to when the current component is no long active

Returns: Observable

Returns an observable

dismiss(data, role , navOptions)

Dismiss the current viewController

Param Type Details
data any

Data that you want to return when the viewController is dismissed.Optional

role any

Optional

navOptions NavOptions

Options for the dismiss navigation.

Returns: any

data Returns the data passed in, if any.

enableBack()

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.

getContent()

Returns: component

Returns the Page's Content component reference.

hasNavbar()

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.

index

Get the index of the current component in the current navigation stack.

Returns: number

Returns the index of this page within its NavController.

isFirst()

Returns: boolean

Returns if this Page is the first in the stack of pages within its NavController.

isLast()

Returns: boolean

Returns if this Page is the last in the stack of pages within its NavController.

onDidDismiss()

Called when the current viewController has be successfully dismissed

onWillDismiss()

Called when the current viewController will be dismissed

pageRef()

Returns: ElementRef

Returns the Page's ElementRef.

setBackButtonText(val)

Change the title of the back-button. Be sure to call this after ionViewWillEnter to make sure the DOM has been rendered.

Param Type Details
val string

Set the back button text.

showBackButton(Set)

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.

Param Type Details
Set boolean

if this Page's back button should show or not.

willEnter

Observable to be subscribed to when the current component will become active

Returns: Observable

Returns an observable

willLeave

Observable to be subscribed to when the current component will no longer be active

Returns: Observable

Returns an observable

willUnload

Observable to be subscribed to when the current component has been destroyed

Returns: Observable

Returns an observable

API

Native

General