In my application, there is a text box that looks like this -
<input type="text" class="form-control" id="inputID" name="ItemId" ng-model="inputItemId" ng-required="true" ng-blur="addValueToArray(inputItemId)"/>
The user has the ability to add or remove these text boxes based on their needs. All the entered values from these text boxes are stored in an array like so -
$scope.itemIDs = [];
$scope.addValueToArray = function(inputItemId)
{
$scope.validID = $filter('uppercase')(inputItemId);
$scope.itemIDs.push($scope.validID);
}
All the IDs the user enters get added to the $scope.itemIDs array.
For example, let's say the current values in this array are - ABC, ABD, ABE, ABZ for different items.
Now, if a user wants to update the second value from ABD to ABW, as per how my function works, it simply adds ABW at the end of the array resulting in - ABC, ABD, ABE, ABZ, ABW.
Is there a way in Angular where I can replace the existing value in the array with a new one instead of adding it to the end? Am I overlooking something?