一行有三列,但是当我把值放到第一列时,它会自动转到其他两列

I have three column in a row but when I put value in first column it automatically goes to all the other two columns

本文关键字:一列 两列 其他 一行 三列      更新时间:2023-09-26

作为一个初学者,我没有关于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: '',
                })
            },

图片:此处输入图像描述

data-ng-model="location.connectivity[17]"更改为您想要使用的值

从你的代码中不清楚你试图使用什么值。您确定要直接赋值而不是使用ng-repeat吗?