The angular docs say that it supports these two forms of DI setup (plus another, but it's not necessary for this question):
with
var app = angular.module('MyApp', []);
you can
1. app.controller('MainCtrl', function ($scope, $http) { } );
or
2. app.controller('MainCtrl', ['$scope', '$http', function($scope, $http) { } ]);
I have 2 questions about this.
First, I assume they can do the first form of DI by doing function.toString and parsing the string of the function to learn that $scope and $http are the required dependencies. Is that a correct assumption?
Second, it would seem to me that if you use the array form (the one I show 2nd), then Angular wouldn't have to do the string parsing (assuming that is what's happening), and would increase performance (especially depending on how many controllers it's parsing). But I never hear anyone talk about how it is a performance gain. Is it?
I'm not sure any of my assumptions are correct, or even if the performance gain would be worth the effort I've taken to post these questions, but I'd love to get some details on how it all works from someone more familiar with the source than I am.
Edit: The Angular docs do talk about how toString is used. That answers one of my questions.