AngularJS Version: 1.3.8
JSFiddle Link: http://jsfiddle.net/uYFE9/4/
I've been working on a small AngularJS project and encountered an issue. I have implemented an ng-repeat
in a form that gets populated based on the selection from a dropdown menu linked to a model using ng-options
. Here is a snippet of the code:
<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>
Initially, the variable complete
is set to false. Clicking a Next
button will toggle the value of
complete</code, hiding the form and dropdown. Pressing the <code>Back
button will then revert the value of complete</code back, displaying the form again.</p>
<p>The issue arises with the use of <code>ng-if
on the select
element (and previously, when I had the form enclosed in a div
with the same ng-if
). The ng-repeat
stops updating when the selection in the dropdown changes. However, removing the ng-if
from the select
restores the functionality of ng-repeat
.
I am unsure if there is a problem with the nesting structure or if it is a bug within AngularJS itself. Feel free to test it out on the provided JSFiddle link. The $index
should be printed as many times as the selected number in the dropdown, but it does not display correctly.
An interesting observation is that when I debugged this issue on my local setup, having FireBug open seemed to resolve the problem.