我想進入這個格式,需要在屏幕上顯示的JSON數據:如何從angular JS中的獲取請求的輸入字段中獲取數據?
{
"make": "Toyota",
"vin": "1234",
"model": "FJ",
"parts": [
{
"name": "wheel",
"desc": "makes it roll"
},
{
"name": "engine",
"desc": "really shiny"
},
{
"name": "Seats",
"desc": "leather seat covers"
}
]
}
如何輸入字段中填入這些數據?
<form>
<div class="form-group">
<label>Make</label>
<input type="text" class="form-control" id="makeid" ng-modal="make">
</div>
<div class="form-group">
<label>Vin</label>
<input type="text" class="form-control" id="vinid" ng-modal="vin">
</div>
<div class="form-group">
<label>Modal</label>
<input type="text" class="form-control" id="modalid" ng-modal="modal">
</div>
<div class="form-group">
<label>Parts</label>
<input type="text" class="form-control" id="partsid" ng-modal="part">
</div>
</form>
如何使用請求使其工作?
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("http://192.16.1:8080/restproj/v1/dealer/1234/car")
.then(function(response) {
$scope.myMessage = response.data;
});
});
</script>
如何編寫$ scope來填充屏幕?
嘗試納克模態= 「myMessage.vin」。如果它不起作用,請使用你的代碼。 – NNR
對零件使用ng-repeat –
http://jsfiddle.net/u4obssd3/104/ – NNR