我在我的控制器中有两个数组
a = ['1','2','3','4','5'];
b=['2','5','1']
我的代码就是这个。
<div ng-repeat="inputs in b" >
<div ng-repeat="m in a" ng-if="m==inputs">
<label for id="sk_{{inputs}}" > ID </label>
<input type="number" placeholder="Enter "
class="form-control"
id="sk_{{inputs}}" min="1"
ng-model="myModel.sk_{{inputs}}"
ng-required="currentStep == 3" />
</div>
</div>
<button class="btn " ng-click="getvalues();">Next </button>
如何在单击按钮时获取输入字段值。 (我不需要每个输入字段的按钮。)..请帮助我..
这是我的plunker https://plnkr.co/edit/RCEO002i9oTWF8RmytnO?p=preview
答案 0 :(得分:0)
<div ng-repeat="inputs in b" >
<div ng-repeat="m in a" ng-if="m==inputs">
<label for id="sk_{{inputs}}" > ID </label>
<input type="number" placeholder="Enter "
class="form-control"
id="sk_{{inputs}}" min="1"
ng-model="myModel.sk[inputs]"
ng-required="currentStep == 3" />
</div>
</div>
<button class="btn " ng-click="getvalues();">Next </button>
$scope.avail = [];
$scope.getvalues= function() {
angular.forEach($scope.b,function(value){
$scope.avail.push($scope.myModel.sk[value]);
})
alert($scope.avail);
}
这就是我需要的......:)