ViewController
Access various features and information about the current view
Usage
import {Page, ViewController} from 'ionic-angular';
@Page....
export class MyPage{
constructor(viewCtrl: ViewController){
this.viewCtrl = viewCtrl;
}
}
Instance Members
componentType
subscribe()
onDismiss()
dismiss()
enableBack(Check)
Check to see if you can go back in the navigation stack
Param | Type | Details |
---|---|---|
Check |
boolean
|
whether or not you can go back from this page |
boolean
Returns if it's possible to go back from this Page.
index
You can find out the index of the current view is in the current navigation stack
export class Page1 {
constructor(view: ViewController){
this.view = view;
// Just log out the index
console.log(this.view.index);
}
}
number
Returns the index of this page within its NavController.
isFirst()
boolean
Returns if this Page is the first in the stack of pages within its NavController.
isLast()
boolean
Returns if this Page is the last in the stack of pages within its NavController.
hasNavbar()
You can find out of the current view has a Navbar or not. Be sure to wrap this in an onPageWillEnter
method in order to make sure the view has rendered fully.
export class Page1 {
constructor(view: ViewController) {
this.view = view
}
onPageWillEnter(){
console.log('Do we have a Navbar?', this.view.hasNavbar());
}
}
boolean
Returns a boolean if this Page has a navbar or not.
setBackButtonText(backButtonText)
You can change the text of the back button on a view-by-view basis.
export class MyClass{
constructor(viewCtrl: ViewController){
this.viewCtrl = viewCtrl
}
onPageWillEnter() {
this.viewCtrl.setBackButtonText('Previous');
}
}
Make sure you use the view events when calling this method, otherwise the back-button will not have been created
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 wrap this in onPageWillEnter
to make sure the has been compleltly rendered.
Param | Type | Details |
---|---|---|
Set |
boolean
|
if this Page's back button should show or not. |