Angular js not working

This is my html file. The angular.js file is in the java / main / webapp / js folder, and Intellij can see it when I click on it, but the code does not work! I get a printout on the screen {{helloMessage}}, 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> 
+4
source share
1 answer

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

  <body ng-app> 

Take a look at a working example .

+21
source

Source: https://habr.com/ru/post/1494052/


All Articles