我對這個問題中提到的技術頗爲陌生。嘗試使用它們來生成表格。目前,我可以從瀏覽器獲取表格的json格式,但即使在控制檯中也不能打印(在.js
文件中)。這是什麼原因?無法使用angularjs,HTML和REST打印表格
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返回的數據?你是否嘗試打印一些字符串而不是響應值? –
我在瀏覽器中打印了值,它工作正常。 –
數據呢?您可以驗證服務退貨數據嗎? –