Trying to understand the differences between CanActivate and CanActivateChild

前端 未结 3 1458
误落风尘
误落风尘 2021-02-19 21:10

So, I\'m trying to protect the access to several routes by using guards. I\'m using the following routes to do so :

const adminRoutes : Routes = [
  {
    path:          


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 21:43

    In your example you have called canActivate inside canActivateChild, hence both the guards are getting called when you are traversing among child routes. If you were to have different authentication logic inside both the guards, your canActivate guard won't execute while traversing among child routes.

提交回复
热议问题