AngularAngular4 的 fireAuth
AngularfireAuth for Angular 4
有人知道 Angularfire - Angular 4 signInWithEmailAndPassword
方法的新代码吗?
loginWithEmail(email: string, password: string): Promise<any> {
return this.afAuth.auth.signInWithEmailAndPassword(email, password));
}
这个returns错误:
Type 'firebase.Promise<any>' is not assignable to type 'Promise<any>'.
您可以通过导入 firebase
并将 Promise<any>
更改为 firebase.Promise<any>
来避免错误。
import * as firebase from 'firebase';
loginWithEmail(email: string, password: string): firebase.Promise<any> {
return this.afAuth.auth.signInWithEmailAndPassword(email, password);
}
import { AngularFireAuth } from 'angularfire2/auth';
/**
* @Description: Global function
* @param gpAfAuth
* @Author: gpCoders
*/
constructor(private gpAfAuth: AngularFireAuth) { }
/**
* @Description: Authorize user
* @Author: gpCoders
*/
gpAuthorize(gpEmail: string, gpPassword: string) {
return new Promise((resolve, reject) => {
this.gpAfAuth.auth.signInWithEmailAndPassword(gpEmail, gpPassword)
.then(userData => resolve(userData),
err => reject(err));
});
}
有人知道 Angularfire - Angular 4 signInWithEmailAndPassword
方法的新代码吗?
loginWithEmail(email: string, password: string): Promise<any> {
return this.afAuth.auth.signInWithEmailAndPassword(email, password));
}
这个returns错误:
Type 'firebase.Promise<any>' is not assignable to type 'Promise<any>'.
您可以通过导入 firebase
并将 Promise<any>
更改为 firebase.Promise<any>
来避免错误。
import * as firebase from 'firebase';
loginWithEmail(email: string, password: string): firebase.Promise<any> {
return this.afAuth.auth.signInWithEmailAndPassword(email, password);
}
import { AngularFireAuth } from 'angularfire2/auth';
/**
* @Description: Global function
* @param gpAfAuth
* @Author: gpCoders
*/
constructor(private gpAfAuth: AngularFireAuth) { }
/**
* @Description: Authorize user
* @Author: gpCoders
*/
gpAuthorize(gpEmail: string, gpPassword: string) {
return new Promise((resolve, reject) => {
this.gpAfAuth.auth.signInWithEmailAndPassword(gpEmail, gpPassword)
.then(userData => resolve(userData),
err => reject(err));
});
}