I read this tutorial to connect my AngularJS application using google login. I added a google button as follows (just copy the tutorial):
In my head, I added a meta tag:
<meta name="google-signin-client_id" content="YOUR_CLIENT_ID.apps.googleusercontent.com">
Then the button itself is added:
<div class="g-signin2" data-onsuccess="onSignIn"></div>
First, I just copied the onSignIn method (it's just a generic handler so I don't copy it to the question) from the tutorial and put it in the <script>...</script> , and it worked. Now I want to put this method in an Angular controller. Therefore, I created the controller as follows:
app.controller('GoogleCtrl', function() { function onSignIn(googleUser) { var profile = googleUser.getBasicProfile(); console.log('ID: ' + profile.getId()); console.log('Name: ' + profile.getName()); console.log('Image URL: ' + profile.getImageUrl()); console.log('Email: ' + profile.getEmail()); } }
And wrap the button with div:
<div ng-controller="GoogleCtrl"> <div class="g-signin2" data-onsuccess="onSignIn"></div> </div>
My code doesn't get to the onSignIn method, and I'm trying to figure out what I can do.
source share