有人可以给我一些指针,告诉我们如何使用ng-repeat
在数组中显示每个元素的错误的最佳方式下面的一些片段/ pseucode
HTML
<div ng-repeat="validator in validatorArr">
<input type="text" ng-class="{ 'invalid': validator.name.$valid == false }" ng-model="validator.name" />
</div>
<input type="button" value="Update" ng-click="save()"/>
JS
angular.module("myModule").controller("myController",function($scope){
$scope.validatorArr = [];
$scope.validatorArr.push({ name : 'test' , expresion : 'test'});
$scope.save = function(){
for(obj in $scope.validatorArr){
if(obj.name == null){
//what is the best way to mark it as invalid
obj.name.$valid = false;
}
}
}
});
由于