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

willEnter

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

Returns: Observable

Returns an observable

didEnter

Observable to be subscribed to when the current component has 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

didLeave

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

Returns: Observable

Returns an observable

willUnload

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

Returns: Observable

Returns an observable

component

onDidDismiss()

Called when the current viewController has be successfully dismissed

onWillDismiss()

Called when the current viewController will be dismissed

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.

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.

pageRef()

Returns: ElementRef

Returns the Page's ElementRef.

getContent()

Returns: component

Returns the Page's Content component reference.

contentRef()

Returns: ElementRef

Returns the Content's ElementRef.

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.

setBackButtonText(backButtonText)

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
backButtonText 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.

API

Native

General