2015-06-17 58 views
-1

,我有以下config.js一段代碼無限循環的angularJS應用

function config($stateProvider, $urlRouterProvider, $ocLazyLoadProvider, IdleProvider, KeepaliveProvider) { 

    // Configure Idle settings 
    IdleProvider.idle(5); // in seconds 
    IdleProvider.timeout(120); // in seconds 

    $urlRouterProvider.otherwise("/dashboards/dashboard_1"); 

    $ocLazyLoadProvider.config({ 
     // Set to true if you want to see what and when is dynamically loaded 
     debug: true 
    }); 

    $stateProvider 

     .state('dashboards', { 
      abstract: true, 
      url: "/dashboards", 
      templateUrl: "viewsangular/common/content.html", 
     }) 
     .state('dashboards.dashboard_1', { 
      url: "/dashboard_1", 
      templateUrl: "viewsangular/dashboard_1.html", 
      resolve: { 
       loadPlugin: function ($ocLazyLoad) { 
        return $ocLazyLoad.load([ 
         { 
          serie: true, 
          name: 'angular-flot', 
          files: ['Scripts/plugins/flot/jquery.flot.js', 'Scripts/plugins/flot/jquery.flot.time.js', 'Scripts/plugins/flot/jquery.flot.tooltip.min.js', 'Scripts/plugins/flot/jquery.flot.spline.js', 'Scripts/plugins/flot/jquery.flot.resize.js', 'Scripts/plugins/flot/jquery.flot.pie.js', 'Scripts/plugins/flot/curvedLines.js', 'Scripts/plugins/flot/angular-flot.js', ] 
         }, 
         { 
          name: 'angles', 
          files: ['Scripts/plugins/chartJs/angles.js', 'Scripts/plugins/chartJs/Chart.min.js'] 
         }, 
         { 
          name: 'angular-peity', 
          files: ['Scripts/plugins/peity/jquery.peity.min.js', 'Scripts/plugins/peity/angular-peity.js'] 
         } 
        ]); 
       } 
      } 
    }); 
} 
angular 
    .module('inspinia') 
    .config(config) 
    .run(function($rootScope, $state) { 
     $rootScope.$state = $state; 
    }); 

我知道鏈接的觀點是正確的。

不過,我得到以下錯誤 http://screencast.com/t/9dNPbBKl10aL

和頁面是無限循環,從 https://localhost/viewsangular/index.html#

https://localhost/viewsangular/index.html#/Dashboards/Dashboard1

視圖文件在那裏。 http://screencast.com/t/QbPHcN6Voxh

+0

笑,這是真棒。當你拿出懶惰的裝載機時會發生什麼? –

+0

怎麼樣?評論所有解決的代碼塊?我有100個! ( –

+0

)爲了調試的目的,我建議只是逐個拿出一個狀態來開始隔離問題,如果你只用一個狀態來嘗試這個問題,並且和你使用所有狀態時一樣,那麼你就可以開始在一個狀態中解決問題,並希望它可以解決所有問題。 –

回答

2

從這裏http://errors.angularjs.org/1.4.1/$injector/modulerr?p0=inspinia&p1=%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.4.1%2F%24injector%2Fmodulerr%3Fp0%3Doc.lazyLoad

它說,它無法實例化模塊inspinia。所以一定要注入模塊。或者檢查是否有其他內容不會干擾您的代碼。

訪問鏈接 The Angular Module error

+0

,因爲我沒有更多的問題,我不得不重新編輯這一個爲我的新問題,我解決了最後一個問題,請檢查我的新更新 –

+0

根據文件,這是他們做了什麼 '''''ocLazyLoadProvider.config({'{''''''''''''TestModule', 文件:[ 'JS/TestModule.js'] }] });''' 而 '''$ stateProvider.state( '指數',{ URL: 「/」, 決心:{ loadMyService:['$ ocLazyLoad',function($ ocLazyLoad){ return $ ocLazyLoad.load('js/ServiceTest.js'); }] [文件](https:// oclazyload .readme.io/1.0 /文檔/使用,您的路由器) –