I am just starting to explore Angular and I want to tackle some more advanced input validation.
My task involves a table where each row has three text inputs. I need to validate that at least one row has three non-empty input fields. If this criteria is met, I need to display a message.
I'm a bit stuck on how to cleanly achieve this in Angular. Any guidance or assistance would be greatly appreciated.
Here is a snippet of my HTML:
<tr data-ng-repeat="i in [1,2,3,4,5]">
<td data-ng-repeat="i in [1,2,3]">
<input ng-model="choice.selected" ng-change='checkAnswer(choice)' type="text" />
</td>
</tr>
...
<div ng-show="haveCompleteRow">we have a complete row!</div>
And my controller looks like this:
$scope.haveCompleteRow = false;
$scope.checkAnswer=function(choice){
$scope.haveCompleteRow = true; // unsure what to implement here?
}
You can see the issue in action in this plunker: http://plnkr.co/edit/Ws3DxRPFuuJskt8EUqBB