AngularJS Verion: 1.3.8
JSFiddle: http://jsfiddle.net/uYFE9/4/
I've been working on a small AngularJS application, and ran into a bit of a problem. I have an ng-repeat
on a page, which fills in the contents of a form. The amount of items in the form is defined by a dropdown bound to a model, and populated using ng-options
. Something like:
<select id="testAmount" ng-model="selectedItem" ng-options="item.name for item in items"></select>
<form role="form" name="testForm" ng-if="!complete">
<div ng-repeat="i in getNumber(selectedItem.number) track by $index">
{{$index}}
</div>
</form>
Complete
is set to false in the beginning, and hitting a Next
button will toggle complete
and hide the form and dropdown. A Back
button will then toggle complete
back, and show the form again.
The problem I'm having is with the ng-if
on the select (and previously, I had the form wrapped in a div
with the same ng-if
- same problem). The ng-repeat
no longer updates when the select
dropdown is changed. Removing the ng-if
on the select
restores the ng-repeat
to working order.
I'm wondering if there's something strange I'm doing with the nesting here, or if it's actually a bug? You can test it out on the JSFiddle linked above. The $index
should be printed the number of times on the dropdown, but isn't.
Interestingly enough - when debugging the problem on my local machine, having FireBug open fixed the issue.