Google登录后,它不会消失登录按钮

时间:2019-02-19 13:12:49

标签: google-signin angular7

当我在登录后使用Google登录时,登录按钮不会消失,也不会显示注销按钮。但是当我按任意键时,它会显示注销按钮和消失的登录按钮。

@HostListener('window:blur', ['$event'])
tabDeactivation(event) {
        console.log("TAb deactivated")
}

HTML代码

 public googleInit() {
  gapi.load('auth2', () => {
  this.auth2 = gapi.auth2.init({
    client_id: this.clienttId,
      cookiepolicy: 'single_host_origin',
    scope: this.scope
  });
  this.attachSignin(document.getElementById('googleBtn'));
});
}
public attachSignin(element) {

console.log(this.auth2);

this.auth2.attachClickHandler(element, {},
  (googleUser) => {

    this.isLoggedOuts = false;
    const profile = googleUser.getBasicProfile();
    this.googleData.accessToken = googleUser.getAuthResponse().access_token;
    this.googleData.email = profile.getEmail();
    this.googleData.name = profile.getName();
    this.googleData.imageurl = profile.getImageUrl();
    this.googleData.id = profile.getId();
    this.googleData.provider = 'google';
    // this.ngOnInit();
  }, (error) => {
    //  alert(JSON.stringify(error, undefined, 2));
  });

}

我在index.html中添加了此脚本。文件。

因此初始isLoggedOuts为true,而登录后为false。

请帮助

0 个答案:

没有答案