I'm new to Angular JS and in a tutorial they place that the way to create a controller is:
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 },
];
}]);
I want to UNDERSTAND what does each of the parameters is:
- 'TodoController'
- array
- '$scope'
- function
I guess the first one is the name of the controller, and the last one is the TodoController constructor.
But what is '$scope' ? A variable name to use on the HTML, a method name?
Can I send more parameters in the array?
I searched on Angular docs but it is pretty lame with no doc about methods. Searching class code neither gave much more info.