angularngrxngrx-storeangular-router-guardsangular-resolver

Angular - Resolvers and Guards


in my app, I'm resolving the user from the BE after login. I would like to navigate to certain init page base on the role of the user. I have tried doing this with a can activate guard, but because guards are being calculated before resolvers, my user is undefined and the app is stuck. (important to mention, I'm using ngrx to manage state and so my user is saved to the state). Is there any way I could check the role of my user in the can activate guard and somehow await the UserResolver ?


Solution

  • Yes you can, check out Todd Motto's blog Preloading ngrx store with Route Guards. Instead of waiting on the resolver, you can wait on state.