Error: [ng:areq] http://errors.AngularJS.org/1.5.8/ng/areq?p0=HelloCtrl&p1=not%20a%20function%2C%20got%20undefined
我开始用的是1.5.8版本的angular,实现课本上的例子时报错:
<!doctype html>
<html ng-app>
<head>
<script src="angular-1.2.0-rc.2/angular.min.js"></script>
</head>
<body>
<div ng-controller="MyController">
<h1>Hello {{ clock }}!</h1>
</div>
<script type="text/javascript">
function MyController($scope) {
$scope.clock = new Date();
var updateClock = function() {
$scope.clock = new Date();
};
setInterval(function() {
$scope.$apply(updateClock);
}, 1000);
updateClock();
};
</script>
</body>
</html>
解决方法:
我的解决办法很low,就是换了个版本,换到
angular-1.2.0-rc.2