在接收值得组件里面导入ActivatedRoute
路由设置页面传参
{ path: 'view/:mid' , component: ViewComponent},
父级页面路由跳转的实现
<div [routerLink]="['/email/view',mail.id]">页面跳转传值</div>
子页面的Component通过下面的方法可以获取到父页面路由传过来的参数<b>mail.id</b>
//
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute} from "@angular/router";
@Component({
selector: 'app-view',
templateUrl: './view.component.html',
styleUrls: ['./view.component.scss']
})
export class ViewComponent implements OnInit {
constructor(public route: ActivatedRoute) {
//通过这种形式来接收父级页面传过来的值
this.route.params.subscribe(data=>console.log(data.mid))
//或者通过
this.route.params['value']['mid']
}
ngOnInit() {
}
}
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有