Currently I have this jQuery
$('body').on('click','.plot', function(){
var y = $('input[name="gps[]"]').map(function() {return this.value;}).get();
console.log(y);
console.log(y[0]);
});
I've tried the following Angular
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>
I'm trying to change a small process over to work in Angular using ng-click
and I cannot seem to get this to work, could someone help me out?
Note: the inputs get added dynamically so I can never know how much inputs there will be and I'm trying to do this in Angular instead of jQuery