最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Angular js does not work - Stack Overflow

programmeradmin2浏览0评论

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>

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>
Share Improve this question asked Jul 29, 2013 at 12:20 SpringSpring 11.8k30 gold badges121 silver badges190 bronze badges 1
  • yeah that pluralsight video ain't right... maybe it's outdated? – MetaGuru Commented Dec 3, 2013 at 3:00
Add a comment  | 

1 Answer 1

Reset to default 21

You forgot ng-app , put it in the body tag:

 <body ng-app>

Have a look at working example.

发布评论

评论列表(0)

  1. 暂无评论