10 $摘要()迭代到达。中止!使用$ locationProvider.html5Mode(真)时; [英] 10 $digest() iterations reached. Aborting! when using $locationProvider.html5Mode(true);
问题描述
我使用 IE8
。
我得到:!10 $摘要()迭代达到中止
当使用运行时错误 $ locationProvider.html5Mode(真);
我的控制器上
我的code:
angular.module('MyApp的',[],功能($ routeProvider,$ locationProvider){
$ routeProvider.when('/ GET',{
templateUrl:模板/ T1.html',
控制器:RouteCtrl
});
$ routeProvider.when('/ GetT2 / T2',{
templateUrl:模板/ T2.html',
控制器:RouteCtrl
}); $ locationProvider.html5Mode(真);
});
功能MainCntl($范围,$路径,$ routeParams,$位置){
。$ $范围路径= $路线;
。$ $范围位置= $位置;
$ $范围= routeParams $ routeParams。
。$ $范围location.path('/获取');
}功能RouteCtrl($范围,$路线){
$ scope.params = $路线;
}
更新:
T1和T2不包含有关角任何
T1.html:
< H1> T1< / H1>
&所述p为H.; T 1下; / P>
T2.html:
< H1> T2< / H1>
&所述p为H.; T 2&下; / P>
下面是我用我的控制器:
< DIV ID =内容NG控制器=MainCntl>
< DIV NG-视图>< / DIV>
< / DIV>
我不知道如何相关,这是你的问题,但我们有同样的症状,也HTML5模式。我们在这个过程中加入类=NG-应用
HTML元素手动自举,而还。这造成两个角度情况下运行,其中一个我们配置(与html5mode上),另一个使用默认设置。
于是两个实例会打过来 $位置
的内容,它永远不会达到平衡。
解决的办法是确保HTML元素是原始当我们手动引导。
注意::我们正在使用require.js,并将其与元素的异步加载变得特别明显。
I'm using angular.js on IE8
.
I'm getting: "10 $digest() iterations reached. Aborting!"
runtime error when using "$locationProvider.html5Mode(true);
" on my controller.
My Code:
angular.module('MyApp', [], function ($routeProvider, $locationProvider) {
$routeProvider.when('/Get', {
templateUrl: 'Template/T1.html',
controller: RouteCtrl
});
$routeProvider.when('/GetT2/T2', {
templateUrl: 'Template/T2.html',
controller: RouteCtrl
});
$locationProvider.html5Mode(true);
});
function MainCntl($scope, $route, $routeParams, $location) {
$scope.$route = $route;
$scope.$location = $location;
$scope.$routeParams = $routeParams;
$scope.$location.path('/Get');
}
function RouteCtrl($scope, $route) {
$scope.params = $route;
}
UPDATE:
T1 and T2 doesn't contain anything related to angular.
T1.html:
<h1>T1</h1>
<p>T1</p>
T2.html:
<h1>T2</h1>
<p>T2</p>
Here is where I use my controller:
<div id="content" ng-controller="MainCntl">
<div ng-view></div>
</div>
I don't know how relevant this is for your problem, but we had the same symptoms, also from html5 mode. We were manually bootstrapping, and also during that process adding class="ng-app"
to the html element. This caused two angular instances to run, one which we configured (with html5mode on), and another with the default settings.
So the two instances would fight over the contents of $location
and it would never reach equilibrium.
The solution was to ensure that the html element is "pristine" when we bootstrap manually.
Note: we are using require.js, and it became especially evident with the asynchronous loading of elements.
这篇关于10 $摘要()迭代到达。中止!使用$ locationProvider.html5Mode(真)时;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!