作爲一個初學者,我沒有關於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>
控制器:
nearmetros: [{
name: '',
long: '',
lat: '',
}],
addMetro: function()
{
$scope.nearmetros.push({
name: '',
long: '',
lat: '',
})
},
圖片: enter image description here
首先更改所有控制器的名稱,例如。 location.longitude,location.latitude ..和名字sholud下拉或自動完成選擇位置...這樣你就可以根據名稱選擇 –
填充其他兩個字段,這樣它的工作,但我想通過所有來自數組的值,以便我可以輕鬆地將值存儲在數據庫中。像我可以添加更多行醫院,atm,電影院等。 – Hemant