1.查询字符串的方式
链接
<div *ngFor="let list of item.Books" [routerLink]="['/detail',{bookId:list.Book.Id}]"></div>
接受参数代码
this.bookId = this.activedrouted.snapshot.params['bookId'];
2.路由参数的传递方式
链接
gobooklist_click(item:string):void{
this.router.navigate(['/booklist',{categoryId:item}]);
}
接受参数的代码
this.categoryId = this.activaterRouter.snapshot.params['categoryId'];
注:不管是哪种参数传递方式在接受参数的
先要在构造函数中注入代码
public activedrouted:ActivatedRoute,
3.通过本地存储进行参数传递
//存储数据
localStorage.setItem('readerId',JSON.stringify(this.readerId));
//读取数据
localStorage.getItem('readerId');