我正在学习 AngularJS,并试图做一些基本的事情:
<!doctype html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js" type="text/javascript"></script>
<script type="text/javascript">
var myapp = angular.module('MyTutorialApp',[]);
myapp.controller("MyMainController", function($scope){
$scope.understand = "I now understand how the scope works2!";
});
</script>
</head>
<body ng-app='MyTutorialApp'>
<div id='content' ng-controller='MyMainController'>
{{understand}}
</div>
</body>
</html>
但是我收到上面代码的错误,错误提示“错误:参数'MyMainController'不是函数,未定义”
但如果我改用下一个代码,该应用程序将运行
function MyMainController($scope) {
$scope.understand = 'I now understand how the scope works3';
}