作为初学者,我不具备有关 AngularJS 和数组的知识质量,因此我将这个问题放在这里。我有一排名为“靠近地铁站”、“经度”、“纬度”的三列,但是当我将值放入第一列时,它会自动转到所有其他两列。如何将其放入单个数组并分别填充所有列?
HTML:
<div class="input-field col s12 m4">
<input id="near_metro" type="text" data-ng-model="location.connectivity[17]" value="17" name="location.connectivity[17]">
<label for="near_metro" class="">Near Metro Station</label>
</div>
<div class="input-field col s12 m3 ">
<input id="metro_long" type="text" data-ng-model="location.connectivity[17]">
<label for="metro_long" class="">Longitude</label>
</div>
<div class="input-field col s12 m3 ">
<input id="metro_lat" type="text" data-ng-model="location.connectivity[17]">
<label for="metro_lat" class="">Latitude</label>
</div>
Controller :
nearmetros: [{
name: '',
long: '',
lat: '',
}],
addMetro: function ()
{
$scope.nearmetros.push({
name: '',
long: '',
lat: '',
})
},
最佳答案
将 data-ng-model="location.connectivity[17]"
更改为您要使用的值。
从您的代码中不清楚您尝试使用什么值。
您确定要直接分配值而不是使用 ng-repeat
吗?
关于javascript - 我连续有三列,但是当我将值放入第一列时,它会自动转到所有其他两列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39766718/