filmov
tv
Angular 2 route parameters
Показать описание
Text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
Angular 2 Tutorial playlist
Angular 2 Text articles and slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
Tags
activatedroute angular2 params
activatedroutesnapshot
activatedroutesnapshot angular 2
activatedroutesnapshot get url
activatedroutesnapshot params
activatedroutesnapshot component
angular 2 pass parameter to route
angular 2 send parameter to component
In this video we will discuss passing parameters to routes in Angular. Let us understand this with an example. We want to make Employee Code on Employee List component clickable.
{ path: 'employees/:code', component: EmployeeComponent },
Next, in EmployeeListComponent, modify the [td] element that displays employee code to bind it to the route we created above using the routerLink directive as shown below.
[/a]
Explanation of the above code:
1. Notice in this example we are binding routerLink directive to an array.
2. This array is called link parameters array.
3. The first element in the array is the path of the route to the destination component.
4. The second element in the array is the route parameter, in our case the employee code.
getEmployeeByCode(empCode: string): Observable[IEmployee] {
}
Explanation of the above code:
1. This method takes employee code as a parameter and returns that employee object (IEmployee).
2. This method issues a GET request to the Web API service.
3. Once the Web API service returns the employee object, this mehod maps it to IEmployee type and returns it.
In one of our previous videos we have created EmployeeComponent to display employee details. When we created this component, we have hard coded employee data in the component itself. Now let's modify it
1. To retrieve employee details by calling the Angular EmployeeService method getEmployeeByCode() we created above.
2. This method calls the server side Web API service which retrieves that specific employee details from the database.
3. The employee code parameter is in the URL
4. To retrieve the parameter from the URL we are using the ActivatedRoute service provided by Angular
5. Since ActivatedRoute is provided as a service inject it into the constructor just like how we have injected EmployeeService
There are diiferent approaches to reterieve route parameters values. We will discuss all the different approaches and when to use what in our upcoming videos.
providers: [EmployeeService]
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
Slides
Angular 2 Tutorial playlist
Angular 2 Text articles and slides
All Dot Net and SQL Server Tutorials in English
All Dot Net and SQL Server Tutorials in Arabic
Tags
activatedroute angular2 params
activatedroutesnapshot
activatedroutesnapshot angular 2
activatedroutesnapshot get url
activatedroutesnapshot params
activatedroutesnapshot component
angular 2 pass parameter to route
angular 2 send parameter to component
In this video we will discuss passing parameters to routes in Angular. Let us understand this with an example. We want to make Employee Code on Employee List component clickable.
{ path: 'employees/:code', component: EmployeeComponent },
Next, in EmployeeListComponent, modify the [td] element that displays employee code to bind it to the route we created above using the routerLink directive as shown below.
[/a]
Explanation of the above code:
1. Notice in this example we are binding routerLink directive to an array.
2. This array is called link parameters array.
3. The first element in the array is the path of the route to the destination component.
4. The second element in the array is the route parameter, in our case the employee code.
getEmployeeByCode(empCode: string): Observable[IEmployee] {
}
Explanation of the above code:
1. This method takes employee code as a parameter and returns that employee object (IEmployee).
2. This method issues a GET request to the Web API service.
3. Once the Web API service returns the employee object, this mehod maps it to IEmployee type and returns it.
In one of our previous videos we have created EmployeeComponent to display employee details. When we created this component, we have hard coded employee data in the component itself. Now let's modify it
1. To retrieve employee details by calling the Angular EmployeeService method getEmployeeByCode() we created above.
2. This method calls the server side Web API service which retrieves that specific employee details from the database.
3. The employee code parameter is in the URL
4. To retrieve the parameter from the URL we are using the ActivatedRoute service provided by Angular
5. Since ActivatedRoute is provided as a service inject it into the constructor just like how we have injected EmployeeService
There are diiferent approaches to reterieve route parameters values. We will discuss all the different approaches and when to use what in our upcoming videos.
providers: [EmployeeService]
Комментарии