Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular js does not work

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>
like image 670
Spring Avatar asked Nov 30 '22 12:11

Spring


1 Answers

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

 <body ng-app>

Have a look at working example.

like image 142
Ivan Chernykh Avatar answered Dec 10 '22 16:12

Ivan Chernykh