-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
Hello guys,
I'm getting this error "Cannot read property '$setValidity' of undefined". Am I missing something? Below is my code:
<form name="vm.myForm" class="form-horizontal" angular-validator angular-validator-submit='vm.updateMatchScore()' novalidate>
<div class="form-group col-xs-12">
<div ng-repeat="item in vm.items track by $index" class="radio-inline">
<input type="radio"
id="item_{{item.id}}"
name="item_{{item.id}}"
ng-value="{{item.id}}"
ng-model="vm.myViewModel.itemId"
ng-required="true">
<label for="item_{{item.id}}">{{item.description}}</label>
</div>
</div>
<div class="form-group col-xs-12" ng-if="vm.myViewModel.itemId === 1">
<input type="text"
class="form-control"
name="myInput1"
ng-model="vm.myViewModel.myInput1Value"
ng-required="true"
min="0"
max="7"
validator="vm.myCustomValidator(vm.myViewModel.myInput1Value)" />
</div>
<div class="form-group col-xs-12" ng-if="vm.myViewModel.itemId === 2">
<input type="text"
class="form-control"
name="myInput2"
ng-model="vm.myViewModel.myInput2Value"
ng-required="true"
min="0"
max="7"
validator="vm.myCustomValidator(vm.myViewModel.myInput2Value)" />
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
It seems that it is just validating the inputs rendered at the very first and if that input is no longer in the DOM, because the ng-if condition is changed to false by the user interaction, it throw the exception when trying to $setValidity in an element that is not in the DOM. Has anyone had this issue before? Any help will be really appreciated!!
Thank you.
kirajhpang
Metadata
Metadata
Assignees
Labels
No labels