角JS不工作 [英] Angular js does not work
本文介绍了角JS不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的HTML文件。该angular.js文件是在Java /主/ web应用/ JS文件夹和IntelliJ可以看到它时,我点击它,然而code不工作!我得到一个在屏幕上打印{{helloMessage}},而不是世界你好
我是什么在这里失踪?
< HTML和GT;
< HEAD>
< META HTTP-EQUIV =Content-Type的CONTENT =text / html的;字符集= UTF-8/>
<标题>角测试< /标题>< /头>
<身体GT;< H1 NG控制器=HelloWorldCtrl> {{helloMessage}}< / H1>角测试
<脚本SRC =JS / angular.js> < / SCRIPT>
<脚本类型=文/ JavaScript的> 功能HelloWorldCtrl($范围){
$ scope.helloMessage =Hello World的;
}< / SCRIPT>< /身体GT;
< / HTML>
解决方案
您忘记 纳克-app </ code>
,把它放在体
标签:
&LT;机身NG-应用&GT;
看一看工作示例。
This is my html file. The angular.js file is under java/main/webapp/js folder and Intellij can see it when I click on it, yet the code does not work! I get a print on screen {{helloMessage}} and not "hello world"
What am I missing here?
<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>
解决方案
You forgot ng-app
, put it in the body
tag:
<body ng-app>
Have a look at working example.
这篇关于角JS不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文