此問題是昨天發佈的Definition for gapi in an Angular controller?的後續行動。ngDrive沒有定義?
用戶pinoyyid向我指出他的混帳回購協議ngDrive(https://github.com/pinoyyid/ngDrive)
我工作過戒菸開始跑進一個錯誤,在我的控制檯'ngDrive' is not defined
。
這是導致此錯誤
angular.module('ngm.ngDrive')
.provider('OauthService', ngDrive.Config)
.config(function (OauthServiceProvider) {
OauthServiceProvider.setScopes('https://www.googleapis.com/auth/drive.file');
OauthServiceProvider.setClientID('2231299-2bvf1.apps.googleusercontent.com');
OauthServiceProvider.setTokenRefreshPolicy(ngDrive.TokenRefreshPolicy.ON_DEMAND);
OauthServiceProvider.setNoAccessTokenPolicy(999); // 0 = fail, > 0 = retry after x
});
代碼具體的ngDrive.Config
注射服務爲我app.js
文件時,如下圖所示
angular
.module('App', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ui.sortable',
'firebase',
'angular-toArrayFilter',
'ngm.ngDrive'
])
我有我沒問題還按指定的方式放置了庫的腳本標記:
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="bower_components/ngDrive/build/module.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/controllers/login_controller.js"></script>
<script src="scripts/controllers/view_resources_ctrl.js"></script>
<!-- endbuild -->
我不太清楚我在做什麼錯在這裏。我沒有看到指南中可能意外跳過的任何內容。
謝謝你的時間。
你介意把你的app.js文件放在JsFiddle上。我可能只是有一些可能導致錯誤的地方。 –
我做了一個我的App.js和Index.html文件看起來像JsFiddle https://jsfiddle.net/uoLpmaah/1/ –
看到我的主要答案,行'setNoAccessTokenPolicy'應該被刪除。我已經修復了文檔。 – pinoyyid