This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
form.$invalid: true after ng-repeat array shortening #1312
Comments
I've also been struggling with this one for some time. Also happens for me when using array.splice to remove a row. I've tried a number of workarounds none of which have solved it so far. Any suggestions would be gratefully received. |
I've managed to solve my problem, not sure its the correct way, but I'm: 1: using an ng-form with the ng-repeat |
@johnday-github |
I'm able to fix the issue when we want to //The delete action
$scope.removeMyChild = function(currentParent, index){
this.myParentForm.$removeControl(this.myChildForm);
currentParent.myList.splice(index, 1);
} This is not so nice but it works for me. Maybe AngularJS should handle it automatically? Any feedback on this is welcome. |
Duplicate of #1572 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Demonstration (Not by me):
http://jsfiddle.net/ADukg/117/
If you fill in both inputs,
form.$invalid=false
.Then, if you click 'Remove All',
form.$invalid=false
, as expected.However, if you fill none, or one input,
form.$invalid=true
, again, as expected.But... If we click 'Remove All' after,
form.$invalid=true
remains, even though there are no fields in the form.Is there a solution to this?
The text was updated successfully, but these errors were encountered: