Utilizing ng-repeat from an array, I have created a select element:
<select data-ng-model='selectedTagForNew' ng-change="selectedTagForNewChange()" >
<option ng-value="{{tag.arrayindex}}" data-ng-repeat="tag in tags | orderBy:'seq'">{{tag.seq}} {{tag.name}} ({{tag.number}})</option>
</select>
Within my controller, on specific actions, I remove the selected element from the array:
tags.splice($scope.selectedTagForNew,1);
for(i=0;i<tags.length;i++){
tags[i].arrayindex=i;
}
$scope.tags=tags;
The issue arises when, after the first slice(), the last element in the array is selected resulting in $scope.selectedTagForNew being undefined. Consequently, tags[$scope.selectedTagForNew] becomes a null object even though it is displayed in the list. What could be causing this anomaly?
UPDATE: After numerous tests, it appears that ng-repeat does not get updated which causes it to return old values of the model (tag.arrayindex)