ionic 传参界面跳转

html界面:

<div  *ngFor="let item of itemList">
    <ion-chip (click)='gotoOtherPage(item.Name)'>
        <ion-icon name="heart" color="primary"></ion-icon>
        <ion-label>{{item.Name}}</ion-label>
    </ion-chip>
</div>

ts代码:

// 构造函数
 constructor( public router: Router ) {}


// 跳转到项目选择界面
  gotoOtherPage( itemName: string) {
    this.router.navigate( [ '/OtherPage' ] , {
      queryParams: {
        item_name: itemName
      }
    });
  }

跳转界面接受传递过来的参数:

// 定义变量接受参数
public itemName : string ;

// 接收传递过来的参数
getParams () {
    this.activeRoute.queryParams.subscribe(queryParams => {
          this.itemName = queryParams.itemName ;
        });
}

其实很简单,但是不知道就很难!加油!

发布了214 篇原创文章 · 获赞 281 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/lk1822791193/article/details/92430314