As a beginner in Angular 1, I have come to understand that $scope acts as the glue between the view and model.
I am curious about the differences between these three methods of defining a controller:
1)
(function(angular) {
'use strict';
var myApp = angular.module('myApp', []);
myApp.controller('namesCtrl', ['$scope', function($scope) {
$scope.customSpice = 'wasabi';
}]);
})(window.angular);
Is there a specific reason for passing an array with values like ['$scope', function]? Can't we just use the function alone?
2)
angular.module('myApp', []).controller('namesCtrl', function($scope) {
});
3)
(function(angular) {
'use strict';
angular.module('invoice1', [])
.controller('namesCtrl', function namesCtrl() {
this.customSpice = 'wasabi';
});
})(window.angular);
In the third example, how exactly do they bind data to $scope? I came across this example on https://docs.angularjs.org/guide/concepts.