注册成功后,我尝试启动一种新方法。不幸的是,webstorm显示此错误:
不能将类型'void'的参数分配给类型'(value:UserCredential)=> UserCredential | PromiseLike'。
这是我的代码:
@Injectable()
export class AuthService {
constructor(private router: Router) {}
signUp(email: string, password: string) {
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(this.goPersonalData());
}
login(email: string, password: string) {
firebase.auth().signInWithEmailAndPassword(email, password)
.then(success => console.log('its working todo next, goto Main PAge'));
}
goPersonalData() {
this.router.navigate(['/personalData']);
}
}
它发生在这一行:
this.goPersonalData()
答案 0 :(得分:1)
将signup
方法修改为:
@Injectable()
export class AuthService {
...
signUp(email: string, password: string) {
firebase.auth().createUserWithEmailAndPassword(email, password)
.then((res) => {
this.goPersonalData();
});
}
...
}