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.html後にコールバック関数をトリガしません。 誰でもこのコードで何が欠けていると思いますか?角度2は、成功した、Googleのログイン</p> <pre><code><div id="{{googleLoginButtonId}}"></div> </code></pre> <p><strong>onGoogleLoginSuccess</strong>関数が呼び出さ取得されていない
私は自分のウェブサイトにGoogleログインを統合しようとしています。 Googleログインページが消えても何も表示されません。 ありがとう Suresh