aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsdesmond2013-07-12 15:32:05 -0600
committerPawel Kozlowski2013-07-14 16:14:28 +0200
commit1e649c5a813d81ec83a0e0eda35dc7477ac98784 (patch)
tree5dca0f8a962df0d683c28ac91636f944deeb30de
parentd7fde5fcb12ba0bcb8061ad349e22f3513cd6ec6 (diff)
downloadangular.js-1e649c5a813d81ec83a0e0eda35dc7477ac98784.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