0
我創建了一個休息web api並使用AngularJS,我想接收這些json數據並將它們存儲在一個表中。我是AngularJS的新手。我能夠獲得所有的json數據,但我想將它們分成每一行。我不知道如果我做的正確與否,但這裏是我的代碼:AngularJS從webapi獲取數據並存儲在表
的index.html
<!DOCTYPE html>
<html ng-app="demoApp">
<head>
<meta charset="UTF-8">
<title>Angular</title>
<script src="lib/angular.js"></script>
<script src="angularDemo.js"></script>
</head>
<body>
<div ng-controller="demoController">
<table>
<tr>
<th>Id</th>
<th>Question</th>
</tr>
<tr ng-repeat=" quiz values">
<td>{{result.id}}</td> <!-- Does not get any value-->
<td>{{result.question}}</td> <!-- Does not get any value-->
</tr>
</table>
<h1>{{result}}</h1> <!-- gets all the json data -->
</div>
</body>
</html>
JS
var app = angular.module("demoApp", []);
app.controller("demoController", function($scope, $http) {
$http.get("http://localhost:8080/quiz/webapi/quiz")
.then(function(response) {
$scope.result = response.data;
});
});
這是什麼?
回答
你
ng-repeat
不好,如果我明白你的排列結果是在
$scope.result
,那麼你必須做這樣的ng-repeat
:來源
2017-08-16 15:22:22 Drakkin
噢好吧,我想在ng-repeat =「」之後,它應該是某種評論。現在我明白了,謝謝 – bubbles2189
相關問題