From 1e649c5a813d81ec83a0e0eda35dc7477ac98784 Mon Sep 17 00:00:00 2001 From: sdesmond Date: Fri, 12 Jul 2013 15:32:05 -0600 Subject: docs(di): promote registering controllers on modules --- docs/content/guide/di.ngdoc | 10 ++++++---- 1 file 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:
- var MyController = function($scope, dep1, dep2) {
+ someModule.controller('MyController', ['$scope', 'dep1', 'dep2', function($scope, dep1, dep2) {
...
$scope.aMethod = function() {
...
}
- }
- MyController.$inject = ['$scope', 'dep1', 'dep2'];
+ ...
+ }]);
+This avoids the creation of global functions for controllers and also protects against minification.
+
### Factory methods
--
cgit v1.2.3