filmov
tv
Routing - Angular (Tutorial #20)
Показать описание
Routing In angular application helps us to navigate across the components using client side navigation .
And these components we can create using angular cli generate commands :
ng g c users
ng g c about
ng g c contact
Now instead of calling it like that we want to display particular component as per the client request .So we want to load users component here when the url is /users and about component will url is /about and same for contact component /contact
So this thing we can do using Routing in Angular . So the mapping of component with url will done through Routing and to implement routing ,we need to follow 3 steps:
1) Routes Configuration
2) router-outlet
3)Navigation to make is Single page application
Router Imports:
The Angular Router is an optional service that presents a particular component view for a given URL. It is not part of the Angular core. It is in its own library package, @angular/router. Import what you need from it as you would from any other Angular package.
Configuration
A routed Angular application has one singleton instance of the Router service. When the browser's URL changes, that router looks for a corresponding Route from which it can determine the component to display.
Router-outlet
When the url will change it will load our route but where to load the component it will decide by directive router-outlet. Router-outlet acts like a placeholder for the components
RouterLinks
Now you have routes configured and a place to render them, but how do you navigate? The URL could arrive directly from the browser address bar. But most of the time you navigate as a result of some user action such as the click of an anchor tag.
If you liked my channel , subscribe to it and like my videos. For any queries ask you question in comment section
Follow us on:
For more such interesting videos, please subscribe to our channel and stay connected.
If you face any problem how Routing works in Angular 5 then leave a comment below and let me know. I'll be happy to assist you.
And these components we can create using angular cli generate commands :
ng g c users
ng g c about
ng g c contact
Now instead of calling it like that we want to display particular component as per the client request .So we want to load users component here when the url is /users and about component will url is /about and same for contact component /contact
So this thing we can do using Routing in Angular . So the mapping of component with url will done through Routing and to implement routing ,we need to follow 3 steps:
1) Routes Configuration
2) router-outlet
3)Navigation to make is Single page application
Router Imports:
The Angular Router is an optional service that presents a particular component view for a given URL. It is not part of the Angular core. It is in its own library package, @angular/router. Import what you need from it as you would from any other Angular package.
Configuration
A routed Angular application has one singleton instance of the Router service. When the browser's URL changes, that router looks for a corresponding Route from which it can determine the component to display.
Router-outlet
When the url will change it will load our route but where to load the component it will decide by directive router-outlet. Router-outlet acts like a placeholder for the components
RouterLinks
Now you have routes configured and a place to render them, but how do you navigate? The URL could arrive directly from the browser address bar. But most of the time you navigate as a result of some user action such as the click of an anchor tag.
If you liked my channel , subscribe to it and like my videos. For any queries ask you question in comment section
Follow us on:
For more such interesting videos, please subscribe to our channel and stay connected.
If you face any problem how Routing works in Angular 5 then leave a comment below and let me know. I'll be happy to assist you.
Комментарии