我试图在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);
}
试试这个:
ionViewDidLoad() {
console.log(this.navCtrl.getActive().name);
}