Google Sign-In for Websites and Angular 2 using Typescript

后端 未结 5 1494
梦如初夏
梦如初夏 2020-12-02 15:49

I\'m building a site that has a pretty standard RESTful web service to handle persistence and complex business logic. The UI I\'m building to consume this service is using A

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 16:14

    The selected answer by Sasxa also helped me but I found that I can bind this to the onSuccess function using .bind(this), that way I don't have to create the function with a fat arrow.

    ngAfterViewInit() {
      var loginProxy = $.proxy(this.onGoogleLoginSuccess, this);
    
      // Converts the Google login button stub to an actual button.
      gapi.signin2.render(
        this.googleLoginButtonId,
        {
          "onSuccess": loginProxy.bind(this),
          "scope": "profile",
          "theme": "dark"
        });
    }
    

提交回复
热议问题