I'm trying to make my submit button disabled if the input fields from an array are invalid.
Here's my html
<form name="membersForm">
<div ng-repeat="emailInput in emailInputs">
<div class="input-field col s10">
<input id="email{{$index}}" type="email" class="validate email" length="50" maxlength="50" ng-model="email['email_' + $index]" required>
<label for="email{{$index}}">{{emailInput.label}}</label>
</div>
<div class="input-field col s2">
<div class="btn btn-floating waves-effect waves-light red" ng-click="removeEmail($index)">
<i class="material-icons">clear</i>
</div>
</div>
</div>
<div class="col s12">
<a class="btn-floating btn waves-effect waves-light" id="addEmail" ng-click="addEmail()">
<i class="material-icons">add</i>
</a>
</div>
<a class="waves-effect waves-light btn" type="submit" ng-disabled="membersForm.$invalid">
Continue
</a>
</form>
as you can see, I have a button to add more email inputs dynamically.
Here's my controller:
class teamMembersCtrl {
constructor($scope) {
'ngInject';
$scope.emailInputs = [
{
label: 'Email'
}
];
$scope.email = {};
$scope.setCurrentPrice();
$scope.addEmail = function () {
$scope.emailInputs.push({
label: 'Email'
});
}
$scope.removeEmail = function ($index) {
$scope.emailInputs.splice($index,1);
}
}
}
QUESTIONS
How can I make the submit button disabled if there is an email input that's invalid where email inputs are added dynamically with an ng-repeat?
Thanks!