ng-repeat 中的输入文本框验证

Input text Box Validation inside ng-repeat

我有一个 ng-repeat 功能,其中显示 3 个输入文本 boxes.But 理智的按钮似乎没有应用验证(我需要启用 'Save' 按钮只有当我填写所有三个输入)

<form name="myForm" novalidate>
    <div ng-repeat="item in items">
    <input type="text" ng-model=item.name required class="form-control">
    </div>
</form>
<button type="button"  ng-disabled="myForm.$invalid" ng-click="save()">Save</button>

控制器:

$scope.items=[{
                id:1,
                name:VALUE1
              },{
                id:2,
                name:VALUE2
              },{
                id:3,
                name:VALUE3
            }]

您的代码似乎有效 fine.Just 需要知道,如果您的模型为空,那么它将禁用按钮 :-

<div ng-controller="MyCtrl">
<form name="myForm" novalidate>
    <div ng-repeat="item in items">
    <input type="text" ng-model=item.name required class="form-control">
    </div>
</form>
<button type="button"  ng-disabled="myForm.$invalid" ng-click="save()">Save</button>
</div>

function MyCtrl($scope) {
    $scope.items=[{
                id:1,
                name:"VALUE1"
              },{
                id:2,
                name:"VALUE2"
              },{
                id:3,
                name:""
            }]

}

Fiddle