Sign-in with google user in an AngularJS app
Looking at your code, it seems like you might have to add listener for your function. To keep things simple, you can easily integrate google login in your app with this plugin. https://github.com/sahat/satellizer
If you follow the instructions, what you will end up with is window. onSignIn
- try to run it in your browser JS console, now to have the same behaviour you will need to crate that function from your controller.
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());
}
window.onSignIn = onSignIn;
}
Remember that code executed by 3rd party like onSignIn
will need to call $scope.$digest
, so angular is aware of model changes.