/** * Created by iberdichevsky on 3/24/16. */ angular.module("MainApp").directive("googleSignInButton", ['SocialMediaService', function (SocialMediaService) { return { restrict: 'C', link: function ($scope, $element, attr) { gapi.load('auth2', function () { console.log('getAuthInstance'); auth2 = gapi.auth2.getAuthInstance(); if (auth2 == 'undefined' || auth2 == null) { console.log('init'); auth2 = gapi.auth2.init({ client_id: '268812200610-87nstk90shch12vglv53ckfc3vc40csg.apps.googleusercontent.com', cookiepolicy: 'single_host_origin' }); } }); setTimeout(function () { auth2.attachClickHandler($element[0], {}, function (googleUser) { SocialMediaService.onGoogleSignIn(googleUser); $scope.getGoogleVisitor('TDFS Lander'); }, function (error) { console.log("googleUser: " + error); } ); }, 100); } }; }]);