Angular页面跳转

Angular页面跳转的实现

传一个或多个参数

页面跳转请求

<td nzAlign="center">
     <a nzAlign="center" [routerLink]="['/statisticaldetails']"
         [queryParams]='{id:data.id, examName:data.examName, scheduleId:data.scheduleId}'>查看详情</a>
</td>

[routerLink] 为需要跳转的页面路径,取自 ts 的名称 selector: 'app-statisticaldetails',
[queryParams] 为通过路径传递到跳转页面的参数

页面跳转接受参数

this.activate.queryParams.subscribe((data) => {
    if (data.examName) {
        this.examName = data.examName;
        this.examId = data.id;
        this.scheduleId = data.scheduleId;
    }
})

传数组参数

页面跳转传递数组

data:传递的参数数组

/question-addmodule:将要跳转的页面

跳转请求

 const param = Base64.encodeURI(JSON.stringify(data));
 this.router.navigate([`/question-addmodule`, param]);

页面接受方法

 this.activatedRoute.params.subscribe(
            (params: Params) => {
                this.project = JSON.parse(Base64.decode(params['project']));
                if (this.project) {
                    console.log(this.project,'跳转数据')
                }
            }
        );

返回按钮

返回按钮的实现

通过button绑定即可

goback() {
    history.back();
}
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值