这是我的 html 文件。 angular.js 文件位于 java/main/webapp/js 文件夹下,当我点击它时 Intellij 可以看到它,但代码不起作用!我在屏幕上打印出 {{helloMessage}} 而不是“hello world”
我在这里缺少什么?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Angular test </title>
</head>
<body>
<h1 ng-controller="HelloWorldCtrl">{{helloMessage}}</h1>
Angular test
<script src="js/angular.js"> </script>
<script type="text/javascript">
function HelloWorldCtrl($scope){
$scope.helloMessage="Hello World";
}
</script >
</body>
</html>
你忘了ng-app http://docs.angularjs.org/api/ng.directive:ngApp,将其放入body
tag:
<body ng-app>
看一下工作示例 http://plnkr.co/edit/F5uLevaZxg6oe9ovMwwF?p=preview.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)