【发布时间】:2013-06-25 20:01:49
【问题描述】:
我收到一条错误消息,提示我达到了 10 个 $digest 迭代。其他问题,如this one,告诉我这是因为我在迭代变量时更改了它。问题是我正在制作一个真正有用的界面。我的代码目前看起来像这样。
<div ng-repeat="(index, trigger) in triggers" ng-click="select(index)">
<strong ng-bind="trigger.name></strong>
<div ng-show="selected == index" class="span12">
<h5>edit properties</h5>
<div ng-repeat="property in getTriggerProps(trigger.type) ">
<div ng-bind="property.name"></div>
<div ng-switch on="property.name">
<input type="text" ng-switch-when="'text'" ng-model="trigger[property.name]">
<select type="select" ng-switch-when="'select'" ng-model="trigger[property.name]" ng-options="possible for possible in property.options">
</select>
</div>
</div> </div>
</div>
在我的真实代码中,还有更多与 twitter bootstrap 相关的 div 和类,但为了清楚起见,我将它们省略了。
所以,它的作用是遍历一个名为 triggers 的集合。有不同类型的触发器,这些触发器的属性由作用域上名为 `getTriggerProps 的函数返回。
对于返回的属性列表,我根据属性类型创建了一系列输入。属性的模型,将是触发器对象上的实际属性。但这就是我认为我遇到的问题,我在迭代此触发器所在的集合时更改了触发器的属性。
我正在使用 angularjs 1.1.5,我知道这是一个不稳定的版本,但我想使用它的功能。
如果查看我正在处理的整个页面可能会有所帮助,这里有一个公共链接: https://dl.dropboxusercontent.com/u/12041395/neurobot_interface_proposal.html
【问题讨论】:
标签: javascript angularjs