top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is use for Guard in Angular (2/4/5)?

0 votes
536 views
What is use for Guard in Angular (2/4/5)?
posted Jan 4, 2018 by Chahat Sharma

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

In Angular, Guard is used to protecting the Routes. Route guards can also control whether a user can leave a certain route. For example, say the user has typed information into a form on the page, but has not submitted the form. If they were to leave the page, they would lose the information. We may want to prompt the user if the user attempts to leave the route without submitting or saving the information.

Guard Types
There are four different guard types we can use to protect our routes:

CanActivate - Decides if a route can be activated
CanActivateChild - Decides if children routes of a route can be activated
CanDeactivate - Decides if a route can be deactivated
CanLoad - Decides if a module can be loaded lazily

answer Jan 24, 2018 by Manish Tiwari
...