Angular Guard无法访问Angular服务对象

时间:2018-09-02 06:45:32

标签: angularjs-scope angular-services angular-guards angular-auth-oidc-client

我试图访问Angular服务对象(我已经在服务中设置了AuthContext),但是Angular Guard给出了undefined,即使设置正确。

我有登录组件,我首先在内部对其进行调用。它使用Angular Auth Service。 在该服务的构造函数中,我确保AuthContext设置正确。 通过调试,我已经看到该对象可用于所有必需的声明。

但是随后,当我访问常规组件(通过Auth Guard进行保护)时,该Guard中的CanActivate方法无法访问上下文。

知道为什么吗? 这是我的代码的简要概述...

enter image description here

enter image description here

我也尝试过使用控制台日志,它看起来像在服务类之前调用​​的Auth Guard。 但是Auth.Guard,我在构造函数中使用了authservice,并且由于依赖注入,应该调用Service对象。 不知道这是怎么回事...

这是控制台日志 enter image description here

有什么建议吗?

0 个答案:

没有答案
相关问题