3.2在路由时传递数据
路由传递数据有以下3种方式:
实战
实战:在查询参数中传参
<a [routerLink]="['/product']" [queryParams]="{id:1}">带参路由</a> productId: number;
constructor(private routeInfo: ActivatedRoute) {
}
ngOnInit() {
this.productId = this.routeInfo.snapshot.queryParams['id'];
}实战:在路由路径中传递数据
参数快照和参数订阅
Last updated