【发布时间】:2017-08-16 15:19:17
【问题描述】:
我创建了一个 rest web api 并使用 AngularJS,我想接收这些 json 数据并将它们存储在一个表中。我是 AngularJS 的新手。我能够获取所有 json 数据,但我想将它们分成每一行。我不确定我是否正确,但这是我的代码:
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;
});
});
【问题讨论】:
-
这是什么
<tr ng-repeat=" quiz values">?