我试图让 AngularJS 解析来自 Spring Rest Controller 的 JSON 格式的所有数据。我能够获取要解析的数据和所有内容,但是每当 Angular 在循环中重复时,它就会在页面上打印“>”文本。
我的 JavaScript
var HOST_SERVER = "http://localhost:8080";
angular.module('exchange', [])
.controller("Book", function ($scope, $http) {
$http.get(HOST_SERVER + "/exchange/get")
.then(function (response) {
$scope.books = response.data;
});
});
html
<!DOCTYPE html>
<html data-ng-app="exchange">
<head>
<title>The Book Exchange</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="jsengine01.js"></script>
<meta charset="utf-8" />
</head>
<body>
<!-- test stuff-->
<div data-ng-controller="Book">
<div data-ng-repeat="book in books">>
<h1>{{book.title}}</h1>
<h4>By {{book.author}}</h4>
</div>
</div>
</body>
</html>
我测试了 Controller ,它们返回了适当的 json 响应,但如果有帮助的话我也可以发布这些响应
最佳答案
您的代码中有第二个 >
正在重复...
<body>
<!-- test stuff-->
<div data-ng-controller="Book">
<div data-ng-repeat="book in books">> <!-- Remove the second '>' -->
<h1>{{book.title}}</h1>
<h4>By {{book.author}}</h4>
</div>
</div>
</body>
关于javascript - 为什么 AngularJS 在 ng-repeat 中打印 "> ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45556641/