春+ Thymeleaf + AngularJs:第一个示例:没有错误,但不工作
问题描述:
我有一个Spring MVC 4.2.6
项目,webjars
库和Thymeleaf
框架,我想这个很简单的例子(我们称之为模板test.html
在映射控制器/test
):春+ Thymeleaf + AngularJs:第一个示例:没有错误,但不工作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org" xml:lang="en" lang="en"
th:fragment="page" ng-app>
<head>
<title>First Test</title>
<script th:src="@{/webjars/angularjs/angular.js}" type="javascript"></script>
<link th:href="@{/webjars/bootstrap/css/bootstrap.css}" rel="stylesheet"/>
<link th:href="@{/webjars/bootstrap/css/bootstrap-theme.css}" rel="stylesheet"/>
</head>
<body>
<div class="btn btn-default">{{"AngularJS"}}</div>
<div class="btn btn-success">Bootstrap</div>
</body>
</html>
所有资源负荷正常,在控制台没有错误,但AngularJs
不工作(见截图括号):
我在做什么w ^荣,有什么想法?
P.S. Adam Freeman的“Pro AngularJS”一书中有一个稍作修改的例子。
答
感谢大家。它没有工作,因为我已经自动将type="javascript"
添加到<script .../>
中。删除后:
<script th:src="@{/webjars/angularjs/angular.js}"></script>
它开始工作正常。 (为什么!?)。