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.
我是AngularJS的新手。刚刚写了一个简单的Hello World来玩Angular。它似乎不起作用,我无法理解为什么。
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Hello Angular World</title>
</head>
<body>
<h1 ng-controller="HelloWorldCtrl">{{HelloAngularWorld}}</h1>
<script src="angular.js"/>
<script type="text/javascript">
function HelloWorldCtrl($scope) {
$scope.HelloAngularWorld = "Hi World of Angular!";
}
</script>
</body>
</html>
Could you please point on my mistake?
你能指出我的错误吗?
1 个解决方案
#1
2
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>
).
在头部加载AngularJS并将ng-app分配给控制器元素的父节点之一(例如html或body,以便获得)。
See this example from their front page: http://angularjs.org/#add-some-control
从他们的首页看到这个例子:http://angularjs.org/#add-some-control
#1
2
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>
).
在头部加载AngularJS并将ng-app分配给控制器元素的父节点之一(例如html或body,以便获得)。
See this example from their front page: http://angularjs.org/#add-some-control
从他们的首页看到这个例子:http://angularjs.org/#add-some-control