我有一个单页应用程序,我已经与几个同事一起工作超过一年.它是一个角度应用程序,使用angular-ui-router在页面之间移动.有时,第一次访问设置页面时,会抛出以下异常:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.3/$rootScope/infdig?p0=10&p1=%5B%5D
at REGEX_STRING_REGEXP (angular.js:63)
at Scope.$get.Scope.$digest (angular.js:14084)
at Scope.$get.Scope.$apply (angular.js:14308)
at done (angular.js:9532)
at completeRequest (angular.js:9717)
at XMLHttpRequest.requestLoaded (angular.js:9660)
Run Code Online (Sandbox Code Playgroud)
在正常情况下我理解[$ rootScope:infdig],但是观察者数组为空的事实对我来说非常混乱.此外,调试非常困难,因为它偶尔会发生.使用检查器,我能够确定正在完成的请求是加载设置HTML文件.从设置页面中删除各种控制器并不能解决问题,即使加载了只加载了常用小部件的设置页面的哑"shell"版本,它似乎也会发生.
我怎样才能弄清楚导致这个空的infdig异常的原因是什么?我该怎样预防呢?
我们正在将我们的应用程序升级到Angular 1.3.0.在这样做的过程中,我们遇到了一些问题,其中大部分问题似乎归结为ngRepeat中ngTransclude的行为.
我们有一个指令重复一堆项目,周围有一个容器,但不拥有该容器的子容器.例如,这是一个简化的例子:
<div ng-controller="myController">
There are {{items.length}} items.
<div my-directive items="items">
This item's name is {{item.name}}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在内部,该指令包含<li ng-repeat="item in items" ng-transclude></li>其中的内容.
在更新之前,这很好.重复的,被转换的元素位于继承自ngRepeat创建的范围的范围内.从更新开始,这些项目都在一个继承自控制器的范围内,据我所知,没有办法访问由ngRepeat创建的范围.
这里有两个JS Bin示例:
我怎样才能在Angular 1.3.0中实现旧的行为或其相似之处?如果这是ngTransclude的预期行为,我怎么能重复一堆子节点而不知道它们是什么?
javascript angularjs angularjs-ng-repeat angularjs-ng-transclude
我们正在项目中使用NodaTime作为时间/日期模型.该项目是一个使用WebAPI的Web应用程序.尝试发布包含LocalTime autoprops的模型时,我们会收到InsufficientExecutionStackException.
为了将我们的项目与此问题隔离开来,我创建了一个新的WebAPI项目.使用NuGet,我将NodaTime和NodaTime.Serialization.JsonNet添加到项目中.在Startup.cs,我ConfigureForNodaTime这样使用:
GlobalConfiguration.Configure(x =>
{
x.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
x.Formatters.JsonFormatter.SerializerSettings.ConfigureForNodaTime(
DateTimeZoneProviders.Tzdb);
});
Run Code Online (Sandbox Code Playgroud)
在(样板ValuesController.cs文件)文件中,我这样被劫持Post:
// POST api/values
public void Post(TestClass input)
{
var x = input;
}
public class TestClass
{
public LocalTime Open { get; set; }
public LocalTime Close { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
当发布此输入模型(通过邮递员),而不是接收本地时间时,我在本文末尾收到错误.
如果我们TestClass如图所示重写,则不会发生错误,并且我们得到正确的本地时间:
public class TestClass
{
public LocalTime;
public LocalTime;
}
Run Code Online (Sandbox Code Playgroud)
我能做些什么来让应用程序与autoprops一起工作吗?虽然我可以(也可能会)开始用字段替换autoprops,但了解这里发生的事情会很好.
这是整个错误,从中间删除了800个任意行:
{
"message":"An error has occurred.",
"exceptionMessage":"Insufficient stack to continue executing the program safely. This …Run Code Online (Sandbox Code Playgroud)