0
目前我有這個jQuery了jQuery角獲得輸入字段值
$('body').on('click','.plot', function(){
var y = $('input[name="gps[]"]').map(function() {return this.value;}).get();
console.log(y);
console.log(y[0]);
});
我已經試過以下角度
theApp.controller('MenuSideController', ['$scope', function($scope) {
$scope.addnewmarker = function() {
var newdiv = document.createElement('div');
newdiv.innerHTML = "<input type='text' name='gps[]' placeholder='Enter Address or Lat/Lon'>";
document.getElementById('marker').appendChild(newdiv);
counter++;
};
$scope.plotmarkers = function() {
var y = document.getElementsByName('gps[]').map(function() {
return this.value;
}).get();
}
console.log(y);
};
}]);
HTML
<div id="marker">
<input type="text" name="gps[]" id="gps">
<input type="text" name="gps[]">
</div>
<input type="button" value="Add another marker input" ng-click="addnewmarker();"></br>
<button class="plot btn" ng-click="plotmarkers()">Plot</button>
我想通過使用ng-click
和I c來改變一個小的流程以在Angular中工作annot似乎得到這個工作,有人可以幫我嗎?
注:輸入獲得動態添加的,所以我可以永遠不知道有多少投入會有,我試圖做到這一點的角度,而不是jQuery的
我看到你說的話有,但我只是想如果那是可以從輸入提取數據? – ngplayground