无法打印带有angularjs,HTML和REST的表格
Can't print table with angularjs, HTML and REST
我对问题中提到的技术很陌生。尝试使用它们生成表。目前,我可以从浏览器中获取表格的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;
});
});
休息:
@RequestMapping(value = "/books", method = RequestMethod.GET)
ResponseEntity<Collection<Book>> allOffices() {
return new ResponseEntity<Collection<Book>>(bookRepository.findAll(),
HttpStatus.OK);
}
每个 HTML 只能自动引导一个 AngularJS 应用程序 公文。在文档中找到的第一个 ngApp 将用于定义 要作为应用程序自动引导的根元素。运行多个 HTML 文档中的应用程序,您必须手动引导它们 改用 angular.bootstrap。AngularJS 应用程序不能 相互嵌套。
http://docs.angularjs.org/api/ng.directive:ngApp
尝试:
<!doctype html>
<html>
<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>
var booksApp = angular.module('booksApp', []);
books.controller('
不应该是书本吧?
如何检查我的 Web 服务和网页是否正在运行:
首先,使用 Postman
通过 GET 方法向 Web 服务发送请求。如果收到响应,则表示成功。
其次,查找angularjs文档找到您的错误。假设您的 Web 服务的主机是 http://127.0.0.1:5000
,请将url
设置为 http://127.0.0.1:5000/books
。
请确保客户端和服务器端能够工作。
相关文章:
- 可以't让我的if语句处理js中的html表单输入
- 如何设置html元素填充的动画
- 使用JS如何动态更改显示的html文件中的文本背景颜色
- 如何将HTML id分配给元素,以及如何将JavaScript应用于元素
- 如何编写HTML输入的JS内联
- Dojo不解析自定义小部件的模板html中的小部件声明性
- 使用javascript将动态表从一个html页面打印到另一个html页
- 通过javascript重定向html传递php变量
- 如何使Javascript动态html表及其上的事件
- 在chrome.tabs.onCreated之后加载HTML页面
- 通过JS和html调用REST API
- 无法打印带有angularjs,HTML和REST的表格
- 如何通过 dojo 在 html 中调用 json rest 服务
- 如何在html应用程序中保护解析的Rest API密钥
- 无法使用参数从html/javascript调用rest web服务
- 从HTML页面调用和显示REST或SOAP响应
- 需要实现html按钮访问REST获取资源
- 通过REST调用Sitecore数据到HTML中
- 如何在javascript文件中调用REST(没有HTML)
- Node JS REST API,现在我如何提供HTML文件