1.

How Routing Works In Angular 2.?

Answer»

Routing is a MECHANISM which enables user to navigate between views/components. Angular 2 simplifies the routing and provide flexibility to configure and define at module LEVEL (Lazy loading). 

The angular application has single instance of the Router service and whenever URL changes, corresponding Route is matched from the routing configuration array. On successful match, it applies redirects and the router builds a tree of ActivatedRoute objects and contains the current state of the router. Before redirection, the router will CHECK whether new state is permitted by running guards (CanActivate). Route Guards is simply an interface method that router runs to check the route AUTHORIZATION. After guard runs, it will resolve the route data and activate the router state by INSTANTIATION the required components into <router-outlet> </router-outlet>. 

Routing is a mechanism which enables user to navigate between views/components. Angular 2 simplifies the routing and provide flexibility to configure and define at module level (Lazy loading). 

The angular application has single instance of the Router service and whenever URL changes, corresponding Route is matched from the routing configuration array. On successful match, it applies redirects and the router builds a tree of ActivatedRoute objects and contains the current state of the router. Before redirection, the router will check whether new state is permitted by running guards (CanActivate). Route Guards is simply an interface method that router runs to check the route authorization. After guard runs, it will resolve the route data and activate the router state by instantiation the required components into <router-outlet> </router-outlet>. 



Discussion

No Comment Found