angular - 错误无法解析 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;
}
}
怎么了?
解决方案
抱歉,我刚刚修复了它,问题是我没有使用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;
}
推荐阅读
- express - 现有的 Repl.it Express Mongoose 应用程序现在拒绝连接到 MongoDB Atlas
- json - pandas json_normalize 嵌套 json,其中字典仅存在于某些记录上
- java - 无法插入数据java mysql
- c# - asp.net 小吃店在按钮单击 c# 上不起作用
- arrays - 从pine中的字符串数组中提取字符串值
- discord.js - 在 Discord.JS 中定义用户的替代方法
- python - Mongo 字段未包含在聚合中(PyMongo)
- php - 干预图像 - 无法从给定的 url 初始化 - Laravel
- r - R Markdown:xtable 部分用 PDF 的代码编织
- julia - 如何去除 Lightgraphs 中的自环