I am new to angular.js, and went through several tutorials, including all of the ones here on codeschool. I found them very useful, and learned a lot. But now that I have finished my "introduction" and am getting into trying to use it in some things, I am finding some confusing inconsistencies, most notably, "dependency injection".
In the tutorials I took, dependencies for services were done like this;
app.controller('name', [ $http, $scope, function($http, $scope) {
// .. code ... //
}]);
This strikes me as odd, but it works anyway. I was confused as to why the [] didn't terminate before the function (I am presuming this is what you refer to as a 'callback' function in javascript?). I was expecting it more like require.js where it would have been ...
app.controller('name', [ '$http', '$scope' ], function($http, $scope) { });
However then I began to look at examples and demos of angular online, and I found this wasn't consistent. For instance, examine the following links;
In each of these, I see dependency injection used like this;
app.controller('name', function($http, AdvancedGithubUser) { });
app.controller('name', function($scope){ });
function controllerName($scope) { };
They completely bypass the array like syntax, and all three are different. In one, it takes a type of object that is declared somewhere else, but I don't see any wiring done to point to it.
In another, it just kind of has these objects.
And still in another, the 'name' part of the controller is the name of the function, and I see nothing that really denotes it as a controller, but it is used that way in directives.
Can anyone explain this to me? I am completely lost now. This inconsistency makes it a bit difficult to pick up the techniques.