在app init时从服务方法中获取价值

时间:2018-03-20 23:46:27

标签: angular angularfire2 angular-services

我为用户身份验证提供authService服务,方法为:

  get authenticated(): boolean {
    return this.authState !== null;
  }

我的主页上有组件,我想从authService.authenticated获得响应。

  ngOnInit() {
    console.log(this.authService.authenticated)
  }

但是当我在组件onInit中调用此方法时,即使用户已通过身份验证,也会出现“假”错误。但是如果我退出,然后通过重定向到主页登录,方法返回' true'。

我做错了什么?

顺便说一下,我正在使用AngularFire2 auth。

0 个答案:

没有答案
相关问题