我试图在ionic2中获取当前页面的名称。当页面加载时我得到此错误
Cannot read property 'name' of undefined
JS
constructor(public navCtrl: NavController,
public http: Http) {
//this.navCtrl.push(AccountPage)
console.log(this.navCtrl.getActive().name);
}
答案 0 :(得分:1)
试试这个:
ionViewDidLoad() {
console.log(this.navCtrl.getActive().name);
}