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