<分区>
我是 Angular JS 的新手,他们在教程中指出创建 Controller 的方法是:
angular.module('app', [])
.controller('TodoController', ['$scope', function ($scope) {
$scope.todos = [
{ title: 'Learn Javascript', completed: true },
{ title: 'Learn Angular.js', completed: false },
{ title: 'Love this tutorial', completed: true },
{ title: 'Learn Javascript design patterns', completed: false },
{ title: 'Build Node.js backend', completed: false },
];
}]);
我想了解每个参数的作用:
- 'TodoController'
- 数组
- '$范围'
- 功能
我猜第一个是 Controller 的名字,最后一个是TodoController的构造函数。
但是 '$scope'
是什么?在 HTML 上使用的变量名,方法名?
我可以在数组中发送更多参数吗?
我搜索了 Angular 文档,但没有关于方法的文档非常蹩脚。搜索类代码都没有提供更多信息。