【发布时间】:2016-12-05 14:52:39
【问题描述】:
我想学习 AngularJS 以在 JSF 页面中使用。这纯粹是学习目的。
我尝试在 jsf 中简单地添加 AngularJS 代码。但似乎它不能识别 AngularJS 代码。它只是在浏览器中输出相同的My first expression: {{ 5 + 5 }}。
我的 jsf 页面
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
</script>
<body>
<div ng-app="hi" >
<p>My first expression: {{ 5 + 5 }}</p>
</div>
</body>
</html>
谁能帮助我如何在 jsf 页面中获取 AngularJS 表达式的输出?或者告诉我一些方向
更新
我的实际意图是从 Managebean 或另一个 jsf 页面获取一些 json 并在此处填充。但作为测试,我尝试创建一个虚拟 json 结构。但 jsf 仍然无法识别 AngularJS 组件。它只是打印
我的第一个表达式:{{ 5 + 5 }}
浏览器控制台打印MyFirstAng.xhtml:24 Uncaught TypeError: app.conntroller is not a function
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myAPP" ng-controller="customerctrl">
<p>My first expression: {{ 5 + 5 }}</p>
<!-- <ul>
<li ng-repeat="x in myData">
{{x.Name + ', ' + x.Age}}
</li>
</ul>
-->
</div>
</body>
<SCRIPT type="text/javascript">
var app = angular.module('myAPP',[]);
app.conntroller('customerctrl', function($scope){
// $scope.myData=[{Name:'jani',Age:'32'}];
});
</SCRIPT>
</html>
【问题讨论】:
-
hi模块在哪里定义?您是否已将其添加到您的索引页?