我試圖使用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