Michael Z Michael Z - 8 months ago 31
AngularJS Question

Simple AngularJS HelloWorld doesn't work

I'm newbie at AngularJS. Just wrote a simple Hello World to play with Angular. It seems it doesn't work and I can't understand why.

<!DOCTYPE html>
<head lang="en">
<meta charset="UTF-8">
<title>Hello Angular World</title>

<h1 ng-controller="HelloWorldCtrl">{{HelloAngularWorld}}</h1>

<script src="angular.js"/>
<script type="text/javascript">
function HelloWorldCtrl($scope) {
$scope.HelloAngularWorld = "Hi World of Angular!";


Could you please point on my mistake?


Load AngularJS in the head and assign ng-app to one of the parents of the controller element (e.g. html or body so you get <html ng-app>).

See this example from their front page: http://angularjs.org/#add-some-control