如何使用离子点击按钮进入另一个页面?
问题描述:
我一直在尝试使用代码,我添加了按钮,但我不知道如何在点击它时将其链接到另一个页面。
I have been trying to work with the code, I added the button but I don't know how to link it to another page when clicking on it.
答
html:
<ion-buttons>
<button ion-button (click)="goAnOtherPage()">Go an Other Page </button>
</ion-buttons>
OR
<ion-label [navPush]="anOtherPage">Go an Other Page</ion-label>
:
import { NavController } from 'ionic-angular';
import { AnOtherPage } from '/anOtherPage';
anOtherPage: AnOtherPage;
constructor(public navCtrl: NavController) {}
goAnOtherPage() {
this.navCtrl.setRoot(anOtherPage);
}