Trying to understand the differences between CanActivate and CanActivateChild

前端 未结 3 1344
后悔当初
后悔当初 2021-02-19 21:20

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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 21:35

    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.

提交回复
热议问题