【发布时间】:2018-02-17 17:02:39
【问题描述】:
我是 angularJS 和 firebase 的新手。最近我在做一个项目,我尝试在用户登录后,用户可以为自己选择一个用户名。 问题是我阅读的教程是基于 firebase 4 的。随着 firebase 5 发生了一些变化。 不起作用的功能是检查用户名 在 AuthService.ts 中它看起来像:
checkUsername(username: string){
username = username.toLowerCase()
return this.db.object(`usernames/${username}`)
}
基于 Firebase4 的 component.ts 看起来像
checkUsername(){
this.authService.checkUsername(this.usernameText).subscribe(username =>{
this.usernameAvaliable = !username.$value
})}
但是,.subscribe 在 firebase 5 中不再存在。我查找了一些解决方案,例如在订阅之前添加 valueChanged。但它仍然无法正常工作。
主函数从firebase获取用户名数据值并检查是否有相同的用户名。
有人知道我应该做什么样的改变吗?
【问题讨论】: