学习一个google 的开发的 前端js 框架 Angular JS。
参照的书: Angular Js published by O'REILLY。
书上第一个简单的小例子:
<html ng-app>
<body ng-controller="TextController">
<p>{{someText}}</p>
<script src="angular.js">
</script>
<script>
function TextController($scope) {
$scope.someText = 'You have started your journey.';
}
</script>
</body>
</html>
正确的写法:
<html ng-app="myApp" >
<head>
</head>
<body>
<div ng-controller='FirsTextController'>
<p>{{someText}}</p>
</div>
<script src="angular.js"></script>
<script>
var app = angular.module("myApp",[]);
app.controller("FirsTextController",function($scope){
$scope.someText = 'You have started your journey.';
})
</script>
</body>
</html>
运行第一个例子就报错 :
Error: [ng:areq] Argument 'TextController' is not a function, got undefined.
这是因为1.3 版本以上不支持定义global controller 所以会出次错误。