aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/content/guide/di.ngdoc10
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/content/guide/di.ngdoc b/docs/content/guide/di.ngdoc
index 5a06a894..241bd656 100644
--- a/docs/content/guide/di.ngdoc
+++ b/docs/content/guide/di.ngdoc
@@ -196,18 +196,20 @@ DI is pervasive throughout Angular. It is typically used in controllers and fact
### DI in controllers
Controllers are classes which are responsible for application behavior. The recommended way of
-declaring controllers is:
+declaring controllers is using the array notation:
<pre>
- var MyController = function($scope, dep1, dep2) {
+ someModule.controller('MyController', ['$scope', 'dep1', 'dep2', function($scope, dep1, dep2) {
...
$scope.aMethod = function() {
...
}
- }
- MyController.$inject = ['$scope', 'dep1', 'dep2'];
+ ...
+ }]);
</pre>
+This avoids the creation of global functions for controllers and also protects against minification.
+
### Factory methods