1goProducts() {
2 this.router.navigate(['/products'], { queryParams: { order: 'popular' } });
3}
4
5http://localhost:4200/products?order=popular
6
7 constructor(private route: ActivatedRoute) { }
8
9 ngOnInit() {
10 this.route.queryParams
11 .filter(params => params.order)
12 .subscribe(params => {
13 console.log(params); // { order: "popular" }
14
15 this.order = params.order;
16 console.log(this.order); // popular
17 }
18 );
19 }