Generate a new Component:

In the NgModule file app.module.ts, find routerModule. forRoot and add a route:



This route information associates the URL with the Component ProductDetailsComponent.

What we want to achieve is that when the user clicks on the product list, they go to the product details page. So open the product-List Component template and add routing information to tag A: [routerLink]=”[‘ /products’, productId]”

Also, the productId variable has not been declared in the Product List Component, so we need to add a line: index as productId:

Final effect:

Click the product Name hyperlink:

Jump to the Product Details page:

For more of Jerry’s original articles, please follow the public account “Wang Zixi “: