【发布时间】:2016-01-21 23:36:34
【问题描述】:
我对问题中提到的技术很陌生。尝试使用它们生成表。目前,我可以从浏览器获取表格的 json 格式,但即使在控制台中也无法打印(在.js 文件中)。这里的原因是什么?
HTML:
<!doctype html>
<html data-ng-app>
<head>
<title>Book</title>
<script src="index.js"></script>
</head>
<body background="/images/library-wall.jpg">
<center>
<div data-ng-app="bookApp">
<div data-ng-controller="bookListCtrl">
<table border = "1">
<tr>
<th>#</th>
<th color = "#0000FF">Title</th>
<th>Author</th>
<th>ISBN</th>
<th>Brief Description</th>
<th>Location</th>
</tr>
<tr data-ng-repeat="book in books">
<td>{{book.id}}</td>
<td>{{book.title}}</td>
<td>{{book.author}}</td>
<td>{{book.isbn}}</td>
<td>{{book.description}}</td>
<td>{{book.location}}</td>
</tr>
</table>
</div>
</div>
JS:
var booksApp = angular.module('booksApp', []);
books.controller('bookListCtrl', function($scope, $http) {
$http.get('books').success(function(data) {
console.log(data);
$scope.books = data;
});
});
REST:
@RequestMapping(value = "/books", method = RequestMethod.GET)
ResponseEntity<Collection<Book>> allOffices() {
return new ResponseEntity<Collection<Book>>(bookRepository.findAll(),
HttpStatus.OK);
}
【问题讨论】:
-
您确定 REST 返回任何数据吗?您是否尝试过打印一些字符串而不是响应值?
-
我在浏览器中打印了这些值,效果很好。
-
数据呢?你能验证服务返回数据吗?
-
@RaufAgayev 请写完整的 html 文件。
标签: javascript java html angularjs