验证由 ng-repeat angularjs 在 jsfile 生成的当前元素
Validate current element which is genegrated by ng-repeat angularjs at jsfile
我想验证在脚本部分由 ng-repeat 生成的元素
<form name="form">
<div ng-repeat=".......">
<input type="text" name="test{{$index}}"/>
<input type="button" ng-click="Check($index)"/>
</div>
</form>
<script>
var Check = function Check(index) {
//How can i check this element valid
//All i want to do like this: $scope.form.test{{index}}.$valid
//It doesn't understand $scope.form.test{{index}}.$valid
if ($scope.form.test{{index}}.$valid)
{
//do something
}
}
</script>
谁能帮帮我。谢谢
if ($scope.form['test' + index].$valid) { }
我想验证在脚本部分由 ng-repeat 生成的元素
<form name="form">
<div ng-repeat=".......">
<input type="text" name="test{{$index}}"/>
<input type="button" ng-click="Check($index)"/>
</div>
</form>
<script>
var Check = function Check(index) {
//How can i check this element valid
//All i want to do like this: $scope.form.test{{index}}.$valid
//It doesn't understand $scope.form.test{{index}}.$valid
if ($scope.form.test{{index}}.$valid)
{
//do something
}
}
</script>
谁能帮帮我。谢谢
if ($scope.form['test' + index].$valid) { }