美文网首页
Ionic3页面传参跳转

Ionic3页面传参跳转

作者: 大大大大橙子呦 | 来源:发表于2019-01-10 19:42 被阅读0次

一.ionic3通过click事件跳转传参

// 在跳转前页面html中,添加click事件
<button (click)="goNews()"></button>

// 在事件中执行跳转
 goNews(){
      this.navCtrl.push('GoodsDetailsPage',{
          id:value
    })
 }

// 接收参数页面,获取传过来的参数
  constructor(private  navParams: NavParams) {
         let id = this.navParams.get('id');
  }

二.ionic通过属性传参跳转

// 在跳转前页面ts中
  constructor() {
      this.pushPage =   NewsPage;  // =后是需要跳转的页面
      this.parms = {id:newsId};   // =后是参数
  }

// 在跳转前页面html中,元素上绑定跳转的页面和参数
<button [navPush]="pushPage " [navParms]="parms "></button>

// 接收参数页面
  constructor(
          private  navParams: NavParams) {
          let id = this.navParams.get('id');  }

相关文章

网友评论

      本文标题:Ionic3页面传参跳转

      本文链接:https://www.haomeiwen.com/subject/gsczrqtx.html