2017-06-13 10 views
1

私はAngularJs + Ruby on Railsアプリケーションを持っていますが、ng-token-authを統合しようとしていますが、実際のロードからアプリを防止:ng-token-authエラー - アプリケーションの読み込みを防止する

jQuery.Deferred exception: Cannot read property 'validateOnPageLoad' of 
undefined TypeError: Cannot read property 'validateOnPageLoad' of 
undefined 
- 
TypeError: Cannot read property 'proxyIf' of undefined 
    at Object.apiUrl (ng-token-auth.self-50017ec….js?body=1:689) 
    at ng-token-auth.self-50017ec….js?body=1:789 
    at Object.invoke (angular.self-5592af5….js?body=1:4626) 
    at request (ng-token-auth.self-50017ec….js?body=1:786) 
    at processQueue (angular.self-5592af5….js?body=1:15758) 
    at angular.self-5592af5….js?body=1:15774 
    at Scope.$eval (angular.self-5592af5….js?body=1:17026) 
    at Scope.$digest (angular.self-5592af5….js?body=1:16842) 
    at angular.self-5592af5….js?body=1:17065 
    at completeOutstandingRequest (angular.self-5592af5….js? 
    body=1:5825) 
- 
TypeError: Cannot read property 'url' of undefined 
    at ng-token-auth.self-50017ec….js?body=1:815 
    at Object.invoke (angular.self-5592af5….js?body=1:4626) 
    at responseError (ng-token-auth.self-50017ec….js?body=1:813) 
    at processQueue (angular.self-5592af5….js?body=1:15758) 
    at angular.self-5592af5….js?body=1:15774 
    at Scope.$eval (angular.self-5592af5….js?body=1:17026) 
    at Scope.$digest (angular.self-5592af5….js?body=1:16842) 
    at angular.self-5592af5….js?body=1:17065 
    at completeOutstandingRequest (angular.self-5592af5….js? 
    body=1:5825) 
    at angular.self-5592af5….js?body=1:6101 
- 
Uncaught TypeError: Cannot read property 'validateOnPageLoad' of undefined 
    at Object.addScopeMethods (ng-token-auth.self-50017ec….js? 
    body=1:168) 
    at Object.initialize (ng-token-auth.self-50017ec….js?body=1:109) 
    at ng-token-auth.self-50017ec….js?body=1:836 
    at Object.invoke (angular.self-5592af5….js?body=1:4626) 
    at angular.self-5592af5….js?body=1:4434 
    at forEach (angular.self-5592af5….js?body=1:322) 
    at createInjector (angular.self-5592af5….js?body=1:4434) 
    at doBootstrap (angular.self-5592af5….js?body=1:1711) 
    at bootstrap (angular.self-5592af5….js?body=1:1732) 
    at angularInit (angular.self-5592af5….js?body=1:1617) 

ここに私のアプリのインデックスとAUTH設定です:

(function(){ 
    'use strict'; 

    angular.module('MyApp', [ 
     'restangular', 
     'ui.router', 
     'templates', 
     'ui.bootstrap', 
     'ng-token-auth' 
    ]).config(authConfig); 

    authConfig.$inject = ['$authProvider']; 

    /** @ngInject */ 
    function authConfig($authProvider) { 
     $authProvider.configure({ 
      apiUrl: 'http://localhost:8000/' 
     }); 
    } 
    })(); 

UPDATE どちらかが私のconfigまたはGETCONFIGが存在しない見つけることができないようです。

addScopeMethods: function() { 
        return c.user = this.user, 
        c.authenticate = angular.bind(this, this.authenticate), 
        c.signOut = angular.bind(this, this.signOut), 
        c.destroyAccount = angular.bind(this, this.destroyAccount), 
        c.submitRegistration = angular.bind(this, this.submitRegistration), 
        c.submitLogin = angular.bind(this, this.submitLogin), 
        c.requestPasswordReset = angular.bind(this, this.requestPasswordReset), 
        c.updatePassword = angular.bind(this, this.updatePassword), 
        c.updateAccount = angular.bind(this, this.updateAccount), 
        this.getConfig().validateOnPageLoad ? this.validateUser({ 
         config: this.getSavedConfig() 
        }) : void 0 
       }, 

getConfig()が定義されていないため、this.getConfig().validateOnPageLoadの上のコードでは失敗します。 getSavedConfig()は、しかし...


私はバックエンドに工夫使用していますので、私の理解は、私はちょうど始めるためにこのような最小限の設定を必要とすることで、期待される設定を返します。

私が提供できる他の情報を教えてください!

答えて

0

私はそれを理解しました!

私はに私の設定を変更:getConfig電子に

function authConfig($authProvider) { 
    $authProvider.configure([{ 
     default: { 
      apiUrl: 'http://localhost:8000/' 
     }, 
     user: { 
      apiUrl: 'http://localhost:8000/' 
     } 
    }]); 
} 

「未定義」が返されましたので、そのreturn t[this.getCurrentConfigName(e)]は、「ユーザー」を返していました、未定義だったが、私は、「ユーザー」という名前の設定がありませんでした。名前付き設定を追加すると、tが設定値の名前であるキーを持つオブジェクトになっているので、この問題は解決されました。

関連する問題