angular传参方式及其数组传参

this.router.navigate(['name',item])

通过这种方式可以进行多个参数的传递。

然后用public Route:ActivatedRoute进行获取参数。是个有效的方式。

const item = {rowlines: JSON.stringify(this.rowlines)};

this.router.navigate(['pic', item]);

///////////////////////////////////////////////////////

export class PicPage {

rowlines = [{pos: 200, lines: {startindex: 0 , endindex: 1}}];

constructor(public router: Router , public route: ActivatedRoute) {

console.log(route.snapshot.paramMap.get('rowlines'));

let rowlines = route.snapshot.paramMap.get('rowlines');

console.log(rowlines = JSON.parse(rowlines))

console.log(rowlines[0]);

}

///////////////////////////////////////////////////////

this.router.navigateByUrl('/app/tab/(search:search)?geohash=' + this.geohash);

这个可以处理有tabs这种特殊的路由。。

猜你喜欢

转载自blog.csdn.net/wangjiali123123/article/details/84575467
今日推荐