aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsdesmond2013-07-12 15:32:05 -0600
committerPawel Kozlowski2013-07-14 16:23:04 +0200
commitcaa12dbc57764b5336be6ef4f6133dc1130b2569 (patch)
tree75b7a557c14cb18fad5411cfe0becb3bf68b1126
parent1122b3c14da4372f5de5a270108663f1cf7e6649 (diff)
downloadangular.js-caa12dbc57764b5336be6ef4f6133dc1130b2569.tar.bz2
docs(di): promote registering controllers on modules
-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