问题
I am trying to access the Angular Service Object (I have set the AuthContext in service) but Angular Guard is giving undefined even though that is well set.
I have login component, which I call first and internally It uses the Angular Auth Service. In the constructor of that service, I ensure that AuthContext is well set. Through the debug, I have seen that object is available with all the required claims.
But then when I access the regular component (which I have guarded through the Auth Guard) CanActivate method in that Guard fails to access the context.
Any idea why? Here is little overview of my code...
I also have tried to use the console log and it looks like Auth Guard called before the service class. But Auth.Guard, I have used authservice in constructor and by virtue of Dependency injection, Service object should get called.. Don't know what's wrong here...
Here is console log
any suggestion?
来源:https://stackoverflow.com/questions/52134624/angular-guard-is-not-able-to-access-the-angular-service-object