Quoted from the Angular tutorial:
To use a service in Angular, you simply declare the names of the dependencies you need as arguments to the controller's constructor function, as follows:
phonecatApp.controller('PhoneListCtrl', function ($scope, $http) {...}
It seems that the controller
method is checking which services you've requested by looking at the argument names, such as $scope
and $http
. But that seems so crude. Is it actually just converting the function to a string and slicing it, like this? Or is there some cleverer behind-the-scenes action going on?
How does it know which services your controller requested?