我是Angular JS的新手,我创建了一个带有输入元素的div,并且我没有在输入框中使用ng-model。Angular JS收集来自div的所有输入值
<div class="row">
<br>
<div class="col-sm-10" id="rankingForm" >
<p ng-repeat=" x in $ctrl.outputProductAttributeValueList">
{{x}} <input type="text" />
</p>
<br>
<button type="submit" ng-click="$ctrl.onRankingFormSubmit()"> SUBMIT</button>
</div>
</div>
当我点击提交按钮,我要访问所有的输入值。请帮助我如何做到这一点。我试过如下。
angular.module("productList")
.component("productList",{
templateUrl : "product-list/product-list.template.html",
controller : ["$http" ,"$scope","$document",function productListController($http,$scope,$document){
var self = this;
self.outputProductAttributeValueList =[ "age", "gender","all"];
self.onRankingFormSubmit = function() {
var queryResult = $document[0].getElementById("rankingForm")
console.log(queryResult);
// HERE queryResult is printing how to proceed further
};
}]
});
现在我想收集所有由ng-repeat动态创建的输入值。请告诉我该怎么做?
你不需要任何验证或检查是t他的数据实际上是否存在? – haxxxton
不需要任何验证 –
所有输入字段都是从服务器响应中动态生成的。那么如何维护所有ng模型变量? –