SCRIPT5022:10 $摘要()迭代到达。中止!并重定向到的index.html [英] SCRIPT5022: 10 $digest() iterations reached. Aborting! and redirecting to index.html

查看:210
本文介绍了SCRIPT5022:10 $摘要()迭代到达。中止!并重定向到的index.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

我试图加载一个引导模式窗格中的一个角JS应用程序,它是在Internet Explorer显示奇怪的行为(我们测试它在IE9和8)。

I am trying to load an Angular JS app in a bootstrap modal pane, and it is displaying strange behaviour on Internet Explorer (We have tested it on IE9 and 8).

我们发现,我们得到以下错误:

we found that we were getting following errors :

**'JSON'未定义
**对象Errorundefined

** 'JSON' undefined ** object Errorundefined

SCRIPT5022: 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [["fn: function $locationWatch() {
  var oldUrl = $browser.url();
  var currentReplace = $location.$$replace;

  if (!changeCounter || oldUrl != $location.absUrl()) {
    changeCounter++;
    $rootScope.$evalAsync(function() {
      if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).
          defaultPrevented) {
        $location.$$parse(oldUrl);
      } else {
        $browser.url($location.absUrl(), currentReplace);
        afterLocationChange(oldUrl);
      }
    });
  }
  $location.$$replace = false;

  return changeCounter;
}; newVal: 7; oldVal: 6"],["fn: function $locationWatch() {
  var oldUrl = $browser.url();
  var currentReplace = $location.$$replace;

  if (!changeCounter || oldUrl != $location.absUrl()) {
    changeCounter++;
    $rootScope.$evalAsync(function() {
      if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).
          defaultPrevented) {
        $location.$$parse(oldUrl);
      } else {
        $browser.url($location.absUrl(), currentReplace);
        afterLocationChange(oldUrl);
      }
    });
  }
  $location.$$replace = false;

  return changeCounter;
}; newVal: 8; oldVal: 7"],["fn: function $locationWatch() {
  var oldUrl = $browser.url();
  var currentReplace = $location.$$replace;

  if (!changeCounter || oldUrl != $location.absUrl()) {
    changeCounter++;
    $rootScope.$evalAsync(function() {
      if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).
          defaultPrevented) {
        $location.$$parse(oldUrl);
      } else {
        $browser.url($location.absUrl(), currentReplace);
        afterLocationChange(oldUrl);
      }
    });
  }
  $location.$$replace = false;

  return changeCounter;
}; newVal: 9; oldVal: 8"],["fn: function $locationWatch() {
  var oldUrl = $browser.url();
  var currentReplace = $location.$$replace;

  if (!changeCounter || oldUrl != $location.absUrl()) {
    changeCounter++;
    $rootScope.$evalAsync(function() {
      if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).
          defaultPrevented) {
        $location.$$parse(oldUrl);
      } else {
        $browser.url($location.absUrl(), currentReplace);
        afterLocationChange(oldUrl);
      }
    });
  }
  $location.$$replace = false;

  return changeCounter;
}; newVal: 10; oldVal: 9"],["fn: function $locationWatch() {
  var oldUrl = $browser.url();
  var currentReplace = $location.$$replace;

  if (!changeCounter || oldUrl != $location.absUrl()) {
    changeCounter++;
    $rootScope.$evalAsync(function() {
      if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).
          defaultPrevented) {
        $location.$$parse(oldUrl);
      } else {
        $browser.url($location.absUrl(), currentReplace);
        afterLocationChange(oldUrl);
      }
    });
  }
  $location.$$replace = false;

  return changeCounter;
}; newVal: 11; oldVal: 10"]]

和许多其他错误

于是,我们发现,有关于IE浏览器3的问题:
1)的JSON不可用
2)用的Bootstrap应用问题
3)问题渲染视图

So, we found that there are 3 problem on IE: 1) JSON was not available 2) Problem with Bootstraping application 3) Problem Rendering view

通过角JS文件会和大量的线程从计算器,如后:

after going through Angular JS documentation and lots of threads from StackOverflow, such as :

'JSON'是在IE中只有

我们发现有所有线程(在AngulaJS IE指南还提到)一些常见的:
*包括JSON2 / JSON3 pollyfills IE浏览器
*请使用IE-毒刃,和pre-声明自定义的标签(我们使用的是自定义的预输入指令,以限制:'E',代替:真)
*使用IE浏览器等的具体说明

We found that there are few common across all threads (also mentioned in AngulaJS IE guide): * Include JSON2/JSON3 pollyfills for IE * use ie-shiv, and pre-declare custom tags (we are using custom typeahead directive, with restrict: 'E', replace: true) * use other IE specific instructions

所以,我做了以下chagnes:

So, I made following chagnes :

var markup = '<div id="ng-app" class="ng-app:myapp" ng-app="myapp" xmlns:ng="http://angularjs.org"><div ng-controller="MyAppAppCtrl"><div ng-view></div></div></div>';
    jQuery('#works-modal').html(markup);
    angular.bootstrap(jQuery('#ng-app'), ['myapp']);   
    jQuery('#works-modal').modal('show');

实现上述更改后,我仍然得到:

After implementing above changes, I was still getting :

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

<一个href=\"https://github.com/angular/angular.js/issues/1417\">https://github.com/angular/angular.js/issues/1417

在试图渲染视图和应用程序被重定向到主页。于是,我就使得建议的更改:

While trying to render view, and application was redirecting to home page. so I tried making changes suggested in :

<一个href=\"https://github.com/RobbinHabermehl/angular.js/commit/c801f91a25b9be6f5b1163c012e63c84cc6a1359\">https://github.com/RobbinHabermehl/angular.js/commit/c801f91a25b9be6f5b1163c012e63c84cc6a1359

现在,我不再收到错误,当我点击链接以显示模态对话框,它会显示弹出一秒钟,然后重定向到主页。

Now, I am no longer getting the error, when I click on link to display the Modal dialog, it displays the pop-up for a sec, then redirects to home page.

如果我设置:

$locationProvider.html5Mode(false)
  .hashPrefix('!');

它工作正常。任何人都面临着类似的问题?任何帮助是AP preciated。

It works fine. Anyone facing similar issue? Any help is appreciated.

更新
我还报告角JS Github上的bug列表在这个问题上,他们告诉我,他们已经固定在1.2版本这个问题:

Update I've also reported this issue on Angular JS Github bug list, they informed me that they have fixed this issue on 1.2 version:

<一个href=\"https://github.com/angular/angular.js/issues/3397\">https://github.com/angular/angular.js/issues/3397

我会检查,如果能解决我的问题,更新这个帖子。

I'll check and update this thread if that resolves my problem.

更新

我更新我的版本的角度,这似乎解决这​​种 10 $摘要()迭代达到。中止!,但是,它似乎仍然被触发URL变化,它导致重定向到主页。

I updated my version of Angular, and this seems to resolve this "10 $digest() iterations reached. Aborting!", however, it still seems to be triggering URL change, leading it to redirect to home page.

让我在这里解释一下我的情况,这样别人就建议我,如果这也正是与此有关与否:

Let me explain my scenario here, so that others can suggest me if this is exactly related to this or not:

我有一个网页说: http://example.com/users/myCollection.html
在这个页面上,我装我的AngularJS应用引导程序模式对话框,当用户点击某个环节,网页里面。在模态加载应用程序的角度路线是: / MYWORK /查找

正在增加的角的版本后,现在,莫代尔似乎加载应用程序的第二个,然后,重定向发生,它去主页。

After upping the version of Angular, now, Modal seems to loading the app for a second, then, redirect happens, and it goes to home page.

仅供参考,我也使用jQuery用于发射角应用在页面上,有冲突的任何机会,因为这个?

FYI, I am also using jQuery on the page that is used to launch the Angular App, is there any chance of conflict due to this?

谢谢,
奸污

推荐答案

我已经summerize我的问题上面,和步骤我把解决这些问题,让我再次summerize,然后我会summerize问题与 10 $摘要()迭代达到中止:!

I've already summerize my problems above, and steps I took to fix those problem, Let me summerize again, then I'll summerize issue with "10 $digest() iterations reached. Aborting!":

第1步)问题与IE浏览器引导应用程序

问题与IE浏览器引导应用程序。我们加载我们的角应用程序内引导模式对话框,并手动自举角应用。由于我们得到错误的渲染来看,我们怀疑这被相关型号要么:我们错过了什么,我们的亲爱的IE不喜欢,或者它根本,我们用我们的自定义使用不喜欢我的自定义指令,或霍根引擎指示。我通过阅读特定的角度JS文件和一个线程#1解决方法。

Issue with bootstrapping application on IE. We are loading our Angular App inside Bootstrap modal dialog, and manually bootstrapping the Angular App. Since we were getting error rendering view, we suspected it be releated to either : we missed something that our "beloved" IE does not like, or, it simply does not like my custom directive, or Hogan Engine that we were using with our custom directive. I resolved them by reading specific Angular JS documentation and one Stackoverflow thread.

我强烈建议大家之后,工作,或打算在角JS工作,你想对IE浏览器使用,请阅读以下内容:

I strongly suggest following everyone, working, or going to work on Angular JS, that you suppose to use on IE, please read following:

  • http://docs.angularjs.org/guide/ie
  • http://docs.angularjs.org/guide/directive
  • Running AngularJS App on Internet Explorer 7

第2步)

步骤1后,我们能够得到应用与html5mode(假),但是,html5mode(真)运行时,仍然是一个问题,对我们来说。一些调试,并加入夫妇的console.log后,我们意识到,即使html5mode(假),申请自举两次。两次?但是,我们手动引导应用程序。
以下是我对引导角应用模板:

After Step 1, we were able to get the App running with html5mode(false), but, html5mode(true), was still a problem, for us. After some debugging, and adding couple of console.log, we realized that even with html5mode(false), application was bootstrapped twice. Twice?, but, we were manually bootstrapping application. Following is my template for bootstrapping Angular app:

var markup = '<div id="ng-app" class="ng-app:myapp" ng-app="myapp" xmlns:ng="http://angularjs.org"><div ng-controller="MyAppAppCtrl"><div ng-view></div></div></div>';
jQuery('#works-modal').html(markup);
angular.bootstrap(jQuery('#ng-app'), ['myapp']);   
jQuery('#works-modal').modal('show');

我们修改上面的模板是这样的:

We modified above template something like :

var markup = '<div id="ng-app" ng-app="myapp" xmlns:ng="http://angularjs.org"><div ng-controller="MyAppAppCtrl"><div ng-view></div></div></div>';
jQuery('#works-modal').html(markup);
angular.bootstrap(jQuery('#ng-app'), ['myapp']);   
jQuery('#works-modal').modal('show');

补充的onclick =返回false;用于启动应用程序的链接的href =#。

added onclick="return false;" href="#" on the link used to launch the app.

注意:如果有在App超链接,请务必正确处理它们,并将它们做你希望他们做什么,因为,HREF,可能会导致位置的变化,这您的应用程序可能不喜欢。

Note : If there are hyperlinks in your App, make sure you handle them properly, and they are doing what you want them to do, because, "href", can cause location change, which your application might not like.

角JS的第3步)更新版本

有情侣在某些角度JS Github上的错误页提到的可能的修复的:

There were couple of possible fix mentioned in some Angular JS Github bug page:

  • https://github.com/angular/angular.js/issues/1417
  • https://github.com/angular/angular.js/issues/3397

一个这样的修复在以下要点中提到:的https://github.com/RobbinHabermehl/angular.js/commit/c801f91a25b9be6f5b1163c012e63c84cc6a1359

one such fix was mentioned in following Gist : https://github.com/RobbinHabermehl/angular.js/commit/c801f91a25b9be6f5b1163c012e63c84cc6a1359

不过,我不舒服修补核心库,更新核心库有自己的缺点的想法,那就是你可能有$ C $的重系数C部分你的应用程序库采用的是德precated,但是,如果有严重的错误修补(如修复了我们所面临的问题)和改进,这总是一展身手。因此,我们将移动到角JS的最新的稳定版本。

However, I was not comfortable with idea of patching core libraries, updating core libraries have their own downside, that is you might have re-factor part of code your application uses from library is deprecated, but, if there are critical bug fixes (like fix for the issue we were facing) and improvement, that's always a go. so, we will move to latest stable build of Angular JS.

现在,我们不再收到错误,并且能够来引导所有的浏览器我们的应用程序(是的,即使是在OMG IE7;))。

Now, we are no longer getting the error, and able to Bootstrap our app on all browsers (yeah, even on OMG IE7 ;) ).

一切都很好,对不对?
好了,正在增加的角的版本之后,现在,莫代尔似乎加载应用程序的第二个,然后,重定向发生,它去主页。

All is well, right? Well, after upping the version of Angular, now, Modal seems to loading the app for a second, then, redirect happens, and it goes to home page.

然而,角JS $位置服务指南($位置服务配置和Hashbang和HTML5模式),这说明,此处的 HTTP://$c$c.angularjs.org/1.2.14/docs/guide/dev_guide.services.$location

However, Angular JS $location service guide ($location service configuration and Hashbang and HTML5 Modes), explains this, here : http://code.angularjs.org/1.2.14/docs/guide/dev_guide.services.$location

HashBang(或HTML5预置模式),需要服务器端的配置,这是一种服务器端的黑客。它真的高达你,如果你'真的'想这样的事情还是不行。

HashBang (or HTML5 fallback mode) requires server side configuration, which is kind of server side "hack". And it's really upto you, if you 'really' want something like this or not.

因此​​,所有现在好了:)

So, all well now :)

希望这是一些使用的任何人使用此或somethign类似的挣扎。

Hope this to be of some use to anyone struggling with this or somethign similar.

再次角JS岩;)

这篇关于SCRIPT5022:10 $摘要()迭代到达。中止!并重定向到的index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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