I am using ionic 2.
I need get previous page name.
here is my code.
@ViewChild(Nav) nav:Nav
constructor() {
this.nav_app.viewDidEnter.subscribe(
view => console.log("Current opened view is : " + view.name);
)
}
still i am getting
Current opened view is : t
How can i get previous page name.
Kindly advice me,
Thanks
You can try
import { Component, ViewChild } from '@angular/core';
import { NavController } from 'ionic-angular';
export class MyApp {
constructor(public navCtrl:NavController){
var val=this.navCtrl.last();
console.log("VAL");
console.log(val);
}
}
In ionic +2 you can simply use:
this.navCtrl.last().name
Here is a simple example to log the name
constructor(public navCtrl:NavController){
console.log("Previous Page is called = " + this.navCtrl.last().name);
}
if you want a history/previous page name in ionic you can use this.
this.navCtrl.getPrevious().name;
or
this.nav.getPrevious().name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With