2017-08-16 24 views
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; 
    }); 
}); 
+0

この "とは何ですか? –

答えて

1

あなたng-repeatが良くない、

結果の配列が$scope.resultであることを理解している場合は、ng-repeatのこの種類を実行する必要があります。

<tr ng-repeat="row in result"> 
    <td>{{row.id}}</td> 
    <td>{{row.question}}</td> 
</tr> 
+0

ああ、私はng-repeat = ""の後で、何らかのコメントであると考えていました。今私は、ありがとう – bubbles2189

関連する問題