gpt4 book ai didi

javascript - Angular JS - module.controller 参数

转载 作者:行者123 更新时间:2023-11-30 09:32:41 24 4
gpt4 key购买 nike

<分区>

我是 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 文档,但没有关于方法的文档非常蹩脚。搜索类代码都没有提供更多信息。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com