角:不能将类型'void'的参数分配给类型'(value:UserCredential)=> UserCredential | PromiseLike <usercredential>'

时间:2018-08-14 09:38:33

标签: angular firebase firebase-authentication

注册成功后,我尝试启动一种新方法。不幸的是,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()

1 个答案:

答案 0 :(得分:1)

signup方法修改为:

@Injectable()
export class AuthService {

    ...

    signUp(email: string, password: string) {

        firebase.auth().createUserWithEmailAndPassword(email, password)
            .then((res) => {
                this.goPersonalData();
            });
    }

    ...
}