试图加载角超过一次 [英] Tried to Load Angular More Than Once

查看:86
本文介绍了试图加载角超过一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自耕农脚手架应用(角fullstack发电机)。

咕噜服务工作正常,但咕噜构建产生很可能是因为圆形是锁定了内存分配,在角引用。

我升级到角 1.2.15 。我得到的错误是:

警告:试图加载角超过一旦

在升级之前,该错误是:

错误:$ 10摘要()迭代到达。中止!

这是pretty难以调试,因为它只有构建/缩小后会发生。我的所有模块都在角的阵列格式,所以微小DI不应该是一个问题,但它是。

有导致此没有单一的脚本。它消失的唯一方法是,如果我不和我的app.js文件进行初始化。我app.js文件如下。

任何事情浮现在脑海中?

 使用严格的;angular.module('对myApp',[
  ngCookies',
  ngResource',
  ngSanitize',
  ngRoute',
  ngTagsInput',
  ui.bootstrap',
  '谷歌地图',
  '火力'
]);angular.module('对myApp')。配置(['$ routeProvider',函数($ routeProvider){
    $ routeProvider
      。什么时候('/', {
        templateUrl:意见/ listing.html',
        控制器:'ListingCtrl
      })
      。除此以外({
        redirectTo:'/'
      });
  }])常数(FIREBASE_URL','东西');


解决方案

这可能是一些问题:基本上它是routeProvider没有找到一个文件,并递归加载默认问题

对于我来说,事实证明,这不是微小,但引起的问题JS的串联。

  angular.module('对myApp')。配置(['$ routeProvider',函数($ routeProvider){
    $ routeProvider
      。什么时候('/', {
        templateUrl:意见/ listing.html',
        控制器:'ListingCtrl
      })
      。除此以外({
        redirectTo:'/'
      });
  }])常数(FIREBASE_URL','东西');

您会发现,如果应用程序无法找到文件(即,否则),那么它会重定向到根,在这种情况下加载 templateUrl 。但是,如果你的 templateUrl 是错误的,那么它会导致重新加载递归 index.html的加载角(和其他一切)一遍又一遍。

在我的情况下,咕噜,CONCAT导致templateUrl是构建后错,而不是之前。

I have a yeoman scaffolded app (the angular fullstack generator).

grunt serve works fine, but grunt build produces a distribution that locks up memory, most probably because of circular references in angular.

I upgraded angular to 1.2.15. The error I get is:

WARNING: Tried to Load Angular More Than Once

Prior to upgrading, the error was:

Error: 10 $digest() iterations reached. Aborting!

It's pretty difficult to debug as it only happens after build / minification. All my modules are in angular's array format, so the minification DI shouldn't be a problem but it is.

There's no single script that causes this. The only way it goes away is if I don't initialize with my app.js file. My app.js file is below.

Any thing come to mind?

'use strict';

angular.module('myApp', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ngRoute',
  'ngTagsInput',
  'ui.bootstrap',
  'google-maps',
  'firebase'
]);

angular.module('myApp').config(['$routeProvider', function ($routeProvider) {
    $routeProvider
      .when('/', {
        templateUrl: 'views/listing.html',
        controller: 'ListingCtrl'
      })
      .otherwise({
        redirectTo: '/'
      });
  }]).constant('FIREBASE_URL', 'something');

解决方案

This could be a number of issues: essentially it's a problem of routeProvider not finding a file and recursively loading the default.

For me, it turned out that it wasn't minification but concatenation of the js that caused the problems.

angular.module('myApp').config(['$routeProvider', function ($routeProvider) {
    $routeProvider
      .when('/', {
        templateUrl: 'views/listing.html',
        controller: 'ListingCtrl'
      })
      .otherwise({
        redirectTo: '/'
      });
  }]).constant('FIREBASE_URL', 'something');

You'll notice that if the app can't find a file (i.e., otherwise), then it will redirect to the root, which in this case loads the templateUrl. But if your templateUrl is wrong, then it will cause a recursion that reloads index.html loading angular (and everything else) over and over.

In my case, grunt-concat caused the templateUrl to be wrong after build, but not before.

这篇关于试图加载角超过一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆