首页 > 解决方案 > 错误无法解析 LoginComponent 的所有参数:实现 Nebular Oauth2 时

问题描述

我正在尝试像在文档中一样使用 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;
  }
}

在此处输入图像描述

怎么了?

标签: angulartypescriptnebularngx-admin

解决方案


抱歉,我刚刚修复了它,问题是我没有使用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;
  }

推荐阅读