I declared a variable called user
outside of the specified scope. However, I am encountering difficulties in accessing this.user within the function
firebase.auth().signInWithPopup(provider).then((result) => {
. It keeps displaying as undefined.
import { ...everything } from 'everything';
@Component({
selector: 'page-login',
templateUrl: 'login.html',
})
interface User{
email: string;
displayName: string;
uid?: string;
photoUrl?: string;
}
export class LoginPage {
user:User;
constructor(...every) {
}
validateForm(form){
if(form.valid){
var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/plus.login');
firebase.auth().signInWithPopup(provider).then((result) => {
const token = result.credential.accessToken;
const userData = result.user;
this.user.email = userData.email;
}).catch(function(error) {
});
}
}
}
}