Let's say I have made a module with a service and a controller in Angular.js, I am able to access that service inside of the controller like so:
var myapp = angular.module('my-app', []);
myapp.factory('Service', function() {
var Service = {};
Service.example = 'hello';
//etc..
return Service;
});
myapp.controller('mainController', function($scope, Service) {
$scope.greeting= Service.example;
});
In this example, the Service object will be passed to the controller, and structuring the code like so will not change the behavior of the code:
myapp.controller('mainController', function(Service, $scope) {
$scope.greeting= Service.example;
});
so, how does Angular.js "know" what the function arguments mean?