0
Ich habe eine Rest Web API erstellt und mit AngularJS, ich möchte diese JSON-Daten erhalten und speichern Sie sie in einer Tabelle. Ich bin neu in AngularJS. Ich konnte alle JSON-Daten erhalten, aber ich möchte sie in jede Zeile aufteilen. Ich bin nicht sicher, ob ich richtig mache oder nicht, aber hier ist mein Code:AngularJS Daten von Webapi und speichern in Tabelle
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;
});
});
Was ist das für '
Antwort
Ihre
ng-repeat
ist nicht gut,Wenn ich verstehe, dass Ihr Array von Ergebnissen in
tun$scope.result
ist, müssen Sie diese Art vonng-repeat
:Quelle
2017-08-16 15:22:22 Drakkin
Oh ok ich dachte nach ng-repeat = "", es soll eine Art von Kommentaren sein. Jetzt sehe ich, danke – bubbles2189
Verwandte Themen