I did some validation check in my dropdown selection when I delete a row. After saving the value I am redirecting to another view. Again when I am trying to delete a row then form is showing undefined. What am I doing wrong?
my jsp-
<div class="form-group" ng-show="editMode!=''">
<label for="editProductJobFileConfig" class="col-md-2 control-label">Job File Configuration</label>
<div ng-class="{'col-sm-9':editMode!=''}" class="col-md-10">
<table class="table table-bordered table-striped table-hover table-condensed">
<thead>
<th>Job File Type</th>
<th>Job File Name</th>
<th></th>
</thead>
<tbody>
<tr ng-repeat="object in editProductJobFileConfig track by $index" novalidate ng-form="jobfileForm">
<td>
<select class="form-control" ng-model="object.key" required ng-change="reValidateJobFileKey(editProductJobFileConfig)" name="jobFileKey" ng-init="object.form = jobfileForm">
<option style="display:none" value=""></option>
<option value="some1">some1</option>
<option value="some2">some2</option>
<option value="some3">some1</option>
<option value="some4">some4</option>
<option value="some5">some5</option>
</select>
</td>
<td>
<input type="text" class="form-control" name="jobFileName" ng-model="object.value" required/>
</td>
<td>
<button class="btn btn-danger btn-sm" data-style="zoom-in" ng-click="deleteFieldMappingDefaults(editProductJobFileConfig,$index)>
<span class="glyphicon glyphicon-remove"></span>
</button>
</td>
</tr>
<tr>
<td colspan="3">
<button class="btn btn-primary btn-sm" ng-click="editProductJobFileConfig.push({'key':'','value':''})" title="Add Value">
<span class="glyphicon glyphicon-plus"></span> Add Value
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
my controller-
$scope.deleteFieldMappingDefaults = function(editProductJobFileConfig, index) {
angular.forEach(editProductJobFileConfig, function(fieldMapO) {
fieldMapO.form.jobFileKey.$setValidity("duplicate",true);
});
for (var i=editProductJobFileConfig.length-1; i>index; i--) {
editProductJobFileConfig[i].form.jobFileKey = editProductJobFileConfig[i-1].form.jobFileKey;
}
editProductJobFileConfig.splice(index,1);
};
1st time when I delete editProductJobFileConfig
holds form and set validity. But once I save my value view is changing, again when I select the same product and try to delete a row it shows form is undefined.