2015-06-17 41 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 /文档/使用,您的路由器) –