0
我有一個API代碼可以生成此特定結果的文本視圖:顯示數據採用NG-重複和NG-模型數據衝突
[
{
"devid": "3",
"name": "abacus",
"type": "math device",
},
{
"devid": "4",
"name": "beaker",
"type": "science device",
}
]
現在,我可以叫我的HTML這個JSON響應文件已經在使用我放入控制器的數組。這是我的控制器代碼:
labserviceService.lab1(id)
.then(function(data){
$scope.device = data.data;
$scope.deviceID = data.data[0].devid;
$scope.devicename = data.data[0].name;
$scope.devicetype = data.data[0].type;
});
如何使用ng-repeat和ng -model在我的div中顯示數據?這是我的div部分
<div class="form-group" ng-repeat="item in device">
<label class="col-md-4 control-label">
ID:
</label>
<div class="col-md-8">
<input type="text" name="regular" class="form-control" ng-model="deviceID">
</div>
<label class="col-md-4 control-label">
Name:
</label>
<div class="col-md-8">
<input type="text" name="regular" class="form-control" ng-model="devicename">
</div>
<label class="col-md-4 control-label">
Type:
</label>
<div class="col-md-8">
<input type="text" name="regular" class="form-control" ng-model="devicetype">
</div>
<br><br>
</div>
我想這個代碼,但時纔會顯示重複的值是第一組,第二個是不顯示的。如何顯示json中的所有數據?非常感謝任何幫助