SoFunction
Updated on 2025-04-04

Detailed explanation of 3 ways to route parameters in Angular5

This article introduces Angular5 routing parameters, a total of 3 methods. Share with you, as follows:

1. The parameters followed by the question mark, the way to obtain the parameters: [id]

For example: /product?id=1&name=iphone can also be: [ routerLink]= "['/books']" [ queryParams]= "{bookname:'"Living"'}

Code: html

<h4>Messages</h4>
<p>Total:{{}}</p>
<div *ngFor="let item of ">
 <b>{{}}</b>:
 <a [routerLink]="['/next',]" [queryParams]="{id:, msg:, name:}">{{}}</a>
 <a routerLink="/final">Reply</a><p></p>
</div>

Get parameters js

ngOnInit() {
 let obj = ["_value"];
 (obj);
}

2. Colon form,

For example: path:/product/:id

How to get parameters: [id]

The first routelink in the above html code is.

In addition, routing needs to be configured

{
 path:'listDetail/:id',
 component:ListDetailComponent
 }

refer tohttps:///article/

The path in the jump

For example: path:/product,component:ProductComponent,data:[{madeInChina:true}]}

How to get parameters: [0][madeInChina]

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.