0
私はrest 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
関連する問題