Make sure to check my new video where I explain a less verbose approach to unit testing the functional guards kzitem.info/news/bejne/s31rz4JtcWWjdI4
@daringuL
4 ай бұрын
A big THANK YOU for this explanation. You saved my day 😁
@CodeShotsWithProfanis
4 ай бұрын
Glad it helped!
@aram5642
Жыл бұрын
I was one of those asking. Thanks for resolving your promise (pun intended)! Since 15.2 there is RouterTestingHarness which makes all of the routing very easy to test.
@khaledsaleh286
6 ай бұрын
Thank you very much for saving me hours trying to figure this out! I don't know how come Angular official documents don't provide an example for them since CanActivate is deprecated now.
@proboyX42
4 ай бұрын
Thank you for this video. This was precise and clear. One question I have. Since I am moving from Ang15 to 17, I want minimal changes so I have created a authGuardService and inside that I am adding canActivate function. And from inside canActivateFn I am calling authGuardSrvice.canActivate(). Is it good approach?
@CodeShotsWithProfanis
4 ай бұрын
If the underlying implementation of the authGuardSrvice.canActivate() is based on the CanActivate interface, then it would be better to migrate the code to the functional approach since this interface has been deprecated. github.com/angular/angular/blob/main/packages/router/src/models_deprecated.ts#L14 If, however, the authGuardSrvice has a collection of functional guards, then it seems to be a good approach. In this case, I would try not to have an injected service but rather an ES module
Пікірлер: 7