1. 程式人生 > >ionic2 頁面跳轉傳參

ionic2 頁面跳轉傳參

1、建立新頁面ionic g page NewPage

2、在app.module.ts完成相應配置

3、從home跳轉到newPage

home.html

<button ion-item (click)="toNewPage()"></button>

   home.ts 
      toNewPage() {
        this.navCtrl.push(NewPage);
      }
4、傳參

home.html

<button ion-item (click)="toNewPage(item)"></button>

  home.ts 
      toNewPage(item) {
          this.navCtrl.push(NewPage,{item:item);
      }
  新頁面取值,newPage.ts
    export class NewPage{
      params
      constructor(
         public navParams: NavParams,
      ) {
      }
       this.params= navParams.get('item');
}