Angular route params

Pubblicato il: 09 aprile 2018
sul canale di: kudvenkat
45,638
266

In this video we will discuss creating a route with parameters and activating the route.

Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
   / @aarvikitchen5572  

Create a route with parameters : To create a route with parameter include a FORWARD SLASH, a COLON and a place holder for the parameter. The example below, creates a route with parameter id.

{ path: 'employees/:id', component: EmployeeDetailsComponent }

You can have more than one parameter in a route. The following route definition creates a route with 2 parameters - id and name.

{ path: 'employees/:id/:name', component: EmployeeDetailsComponent }

Activating the route with parameters : One way to activate the route is by using the routerLink directive.

<a [routerLink]="['employees',2]">
Get Employee with Id 2
</a>

Code Explanation:
Notice in this example we are binding routerLink directive to an array.
This array is called link parameters array.
The first element in the array is the path of the route to the destination component.
The second element in the array is the route parameter, in our case the employee Id.
Another way to activate the route is by using the Angular Router service naviaget() method. Notice to the navigate method also we are passing the same link parameter array.

constructor(private _router: Router) { }

onClick(employeeId: number) {
this._router.navigate(['/employees', employeeId]);
}

Text version of the video
http://csharp-video-tutorials.blogspo...

Slides
http://csharp-video-tutorials.blogspo...

Angular CRUD Tutorial
   • Angular CRUD tutorial  

Angular CRUD Tutorial Text Articles & Slides
http://csharp-video-tutorials.blogspo...

All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...

All Dot Net and SQL Server Tutorials in Arabic
   / kudvenkatarabic  


In questa pagina del sito puoi guardare il video online Angular route params della durata di ore minuti seconda in buona qualità , che l'utente ha caricato kudvenkat 09 aprile 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 45,638 volte e gli è piaciuto 266 spettatori. Buona visione!