I'm getting an error saying that I reached 10 $digest iterations. Other questions like this one, tell me that that is because I'm changing a variable while iterating over it. The problem is that I'm making an interface in which that would be really useful to do. My code currently looks like this.
<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>
In my real code, there are a lot more twitter bootstrap related divs and classes, but I've left them out for clarity.
So, what this does is iterate over a collection named triggers. There are different types of triggers, and the properties of these triggers are returned by a function on the scope called `getTriggerProps.
For the list of returned properties, I create a series of inputs based on the property type. The model of the property, will be the actual property on the trigger object. But that's the problem I think I'm having, I'm changing properties of the trigger while iterating over the collection this trigger is in.
I'm using angularjs 1.1.5, which I'm aware is an unstable version, but I wanted to play with its features.
In case seeing the entire page I'm working on could help, here's a public link: https://dl.dropboxusercontent.com/u/12041395/neurobot_interface_proposal.html