简体   繁体   中英

How to redirect in ionic2

Basically i have explored how we can use get and post in api's using ionic2.

But i have been stucked seriously on how to go to welcome screen after authentication.

This is my html:

<ion-content>
  <ion-list>

    <ion-label>Username</ion-label>
    <input type="text" name="username" [(ngModel)]="model.username">

    <ion-label>Password</ion-label>
    <input type="password" name="password" [(ngModel)]="model.password"><br><br><br>

    <button round block (click)="submit()">Submit</button>

  </ion-list>
</ion-content>

on your ts file

import your welcome screen class and write the below function

import { NavController } from 'ionic-angular';

constructor(public navCtrl:NavController){}

submit(){
  this.navCtrl.push(WelcomeScreen,{});
}

you can use push pop and setRoot depending upon your need to know more about navigation in ionic please refer this link http://ionicframework.com/docs/v2/api/navigation/NavController .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM