通过扩展答案in this question,我自己试图在输入文本字段时隐藏验证消息,
$scope.click = function () {
showVal();
}
function showVal() {
$scope.count = 0;
for (var i = 0; i < $scope.myData.length; i++) {
if ($scope.myData[i].string === "") {
$scope.count++;
}
}
}
我的文字字段是
<div ng-repeat="str in myData">
<input type="text" ng-model="str.string" ng-click="click()">
</div>
<br/> <span ng-if="count >= 1" style="color:red;">One or more string is empty</span>
在this fiddle中给出。为什么在满足条件的情况下验证不会隐藏?