import {Component,Directive,OnInit,NgZone} from 'angular2/core';
declare const gapi:any;
declare const $:any;
@Component({
selector: 'mysite',
templateUrl:'./app/template.html'
})
export class Test{
userAuthToken;
userDisplayName;
constructor(private zone: NgZone){
gapi.load('auth2',this.initnow);
this.zone.run(() => {
console.log(this);
$.proxy(this.onGoogleLoginSuccess, this);
});
}
initnow(){
gapi.auth2.init({client_id:'9511021809-qqke9m46imnmrged8u7u66ilj168bi9t.apps.googleusercontent.com'});
}
ngAfterViewInit() {
gapi.signin2.render(
this.googleLoginButtonId,{
"onSuccess": this.onGoogleLoginSuccess,
"scope": "profile",
"theme": "dark"
});
}
public onGoogleLoginSuccess(loggedInUser) {
this.userAuthToken = loggedInUser.getAuthResponse().id_token;
this.userDisplayName = loggedInUser.getBasicProfile().getName();
console.log("onGoogleLoginSuccess called: ",this.userAuthToken,this.userDisplayName);
}
}
template.htmlWinkel 2 löst keine Callback-Funktion nach erfolgreich Google Login
<div id="{{googleLoginButtonId}}"></div>
onGoogleLoginSuccess Funktion nicht aufgerufen zu werden. Kann jemand vorschlagen, was in diesem Code fehlt?
Ich versuche, Google Login mit meiner Website zu integrieren. aber nichts nach google Login-Seite aufgerufen werden verschwinden. danke Suresh