我一直在阅读一堆角色,我真的很喜欢它。我被要求为我工作的公司开发此应用程序,用户需要使用他们的Google凭证登录。
到目前为止,这是蛋糕,但我认为我太复杂了。到目前为止,这就是我所拥有的:
问题:
这是我的相关角度代码:
app.controller('LoginController', function($scope){
$scope.authResultErrorMessage = "";
$scope.showAuthResultErrorMessage = false;
$scope.userEmail = "";
$scope.handleSignIn = function(authResult){
console.log("I was called!");
if(authResult){
if(authResult['error'] != undefined){
$scope.showAuthResultErrorMessage = true;
$scope.authResultErrorMessage = "Hubo un error. Intente de nuevo. Si este error persiste, ponganse en contacto con el director de IT.";
} else if(authResult['error'] === undefined){
gapi.client.load('plus', 'v1', loadProfileFromGoogle);
}
}
};
$scope.loadProfileFromGoogle = function(){
var request = gapi.client.plus.people.get( {'userId' : 'me'} );
request.execute(getEmail);
console.log(request);
};
$scope.getEmail = function(obj){
$scope.userEmail = obj['emails'].filter(function(v){
return v.type === 'account';
})[0].value;
console.log($scope.userEmail);
$scope.verifyUser($scope.userEmail);
};
$scope.verifyUser = function(email){
$.get('controllers/verifyUser.php', {
data: email,
}, function(result){
console.log(result);
JSON.parse(result);
});
};
});
这是html代码:
<div ng-controller="LoginController as login">
<span id="signin-button">
<span
class="g-signin"
data-callback="login.handleSignIn"
ng-click="login.handleSignIn"
data-approvalprompt="force"
data-clientid="201763423039-kdogu6vm1fgsj6hdnafn5k9otkj9ekjj.apps.googleusercontent.com"
data-cookiepolicy="single_host_origin"
data-requestvisibleactions="http://schemas.google.com/AddActivity"
data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read">
</span>
</span>
</div>
当我点击按钮时,一切顺利,我登录,但在控制台上,以下消息显示:
未找到名为“login.handleSignIn”的回调函数cb = gapi.loaded_0:484
我一直在粉碎我的头几个小时,现在试图弄清楚为什么函数没有被调用,或者就此而言,如果有一种语法错误,目前还没有被高度存在。如果有人能提供帮助,我会非常感激。