Reader small image

You're reading from  Expert Angular

Product typeBook
Published inJul 2017
Reading LevelExpert
PublisherPackt
ISBN-139781785880230
Edition1st Edition
Languages
Right arrow
Author (1)
Sridhar Rao Chivukula
Sridhar Rao Chivukula
author image
Sridhar Rao Chivukula

Sridhar Rao Chivukula is a technical lead at Mindtree Ltd and is based out of New York City. He brings with him more than a decade of rich hands-on experience in all aspects of frontend engineering. He has worked with leading companies such as Oracle, Tech Mahindra, and Cognizant Technology Solutions. He has a Bachelor's degree in Information Technology. He is the author of the books Expert Angular and PHP and Web 2.0 Application Interfaces, published by Packt.
Read more about Sridhar Rao Chivukula

Right arrow

Route Guards

Route Guards let you control various stages of a route navigation. While navigating from one component to another, we need to make sure that the data that will be displayed is authorized for the user, and if not, cancel the navigation.

A Router Guard can return an Observable<boolean> or a Promise<boolean>, and the router will wait for Observable to resolve to either true or false:

  • If the Route Guard returns true, it will proceed with the navigation and display the view
  • If the Route Guard returns false, it will abort/cancel the navigation

There are various Route Guards we can use either independently or in combinations. They are as follows:

  • canActivate
  • canActivateChild
  • canDeactivate
  • Resolve
  • canLoad

The guard function can accept parameters to make a better decision. The parameters we can pass are as follows:

  • component: The custom components directives...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Expert Angular
Published in: Jul 2017Publisher: PacktISBN-13: 9781785880230

Author (1)

author image
Sridhar Rao Chivukula

Sridhar Rao Chivukula is a technical lead at Mindtree Ltd and is based out of New York City. He brings with him more than a decade of rich hands-on experience in all aspects of frontend engineering. He has worked with leading companies such as Oracle, Tech Mahindra, and Cognizant Technology Solutions. He has a Bachelor's degree in Information Technology. He is the author of the books Expert Angular and PHP and Web 2.0 Application Interfaces, published by Packt.
Read more about Sridhar Rao Chivukula