我试图使用Angular Js导入用户的Gmail联系人。该代码工作正常在纯JavaScript,但在角js错误。用angularjs导入Google联系人
HTML代码..
<a class="btn btn-primary btn-simple" ng-click="importgoogle()"><u>Import Gmail Friends</u></a>
角代码..
var clientId = 'Client ID';
var scopes = 'https://www.googleapis.com/auth/contacts.readonly';
$scope.importgoogle = function(){
window.setTimeout(authorize); //calls authorize()
}
var authorize = function(){
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthorization); //calls handleAuthorization()
}
var handleAuthorization = function(){
if (authorizationResult && !authorizationResult.error) {
$.get("https://www.google.com/m8/feeds/contacts/default/thin?alt=json&access_token=" + authorizationResult.access_token + "&max-results=500&v=3.0",
function(response){
console.log(response);
});
}
}
输入用户的ID &密码显示在控制台以下错误消息后..
Uncaught ReferenceError: authorizationResult is not defined
由于此代码在Javascript.Pl中工作,无法理解我要出错的位置缓解帮助..
你确定它是运行的代码吗?在这个代码中它不能得到这个错误。 – Ygalbel
也许你必须刷新/重新加载你的代码 – Ygalbel