我是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模型變量? –