0

我正在尝试像在文档中一样使用 nebular oauth,但是在 logincomponent 中,不同的是我扩展了 nebular login 组件。但是这段代码给了我一个错误

export class LoginComponent extends NbLoginComponent implements OnDestroy {
  public user: SocialUser;
  private loggedIn: boolean;
  constructor(service: NbAuthService,options: {},cd: ChangeDetectorRef, router: Router) {
    super(service,{},cd, router);
  }

  alive = true;

  login() {
    this.service.authenticate('google')
      .pipe(takeWhile(() => this.alive))
      .subscribe((authResult: NbAuthResult) => {
      });
  }

  ngOnDestroy(): void {
    this.alive = false;
  }
}

在此处输入图像描述

怎么了?

4

1 回答 1

1

抱歉,我刚刚修复了它,问题是我没有使用NB_AUTH_OPTIONS注入令牌来解决options ,所以代码应该是这样的

constructor(service: NbAuthService,@Inject(NB_AUTH_OPTIONS) options: {},cd: ChangeDetectorRef, router: Router) {
    super(service,options,cd, router);
  }

  alive = true;
  login() {
    this.service.authenticate('google')
      .pipe(takeWhile(() => this.alive))
      .subscribe((authResult: NbAuthResult) => {
      });
  }
  ngOnDestroy(): void {
    this.alive = false;
  }
于 2020-03-13T04:52:52.987 回答