This time I will show you how to operate Angular5routingpass parameters, and what are thenoteswhen operating Angular5 routing parameters. The following is a practical case, let's take a look.
1. The parameters after the question mark, the way to obtain the parameters: ActivatedRoute.queryParams[id]
For example: /product?id=1&name=iphone can also be :[ routerLink]= "['/books']" [ queryParams]= "{bookname:'《《生》'}
Code: html
Messages
Total:{{msgs.total}}
{{item.name}}: {{item.msg}} Reply
Get parameters js
ngOnInit() { let obj = this.route.queryParams["_value"]; console.log(obj); }
2. Colon form,
For example: path:/product/:id
How to obtain parameters: ActivatedRoute.params[id]
The first routelink in the above html code is.
In addition, routing needs to be configured
{ path:'listDetail/:id', component:ListDetailComponent }
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related matters on the php Chinese website Article!
Recommended reading:
How to operate JS to implement transparency gradient animation
How to use jQuery to traverse XML nodes and attributes
The above is the detailed content of How to operate Angular5 routing parameters. For more information, please follow other related articles on the PHP Chinese website!