Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1e649c5

Browse files
sdesmondpkozlowski-opensource
sdesmond
authored andcommitted
docs(di): promote registering controllers on modules
1 parent d7fde5f commit 1e649c5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/content/guide/di.ngdoc

+6-4
Original file line numberDiff line numberDiff line change
@@ -196,18 +196,20 @@ DI is pervasive throughout Angular. It is typically used in controllers and fact
196196
### DI in controllers
197197

198198
Controllers are classes which are responsible for application behavior. The recommended way of
199-
declaring controllers is:
199+
declaring controllers is using the array notation:
200200

201201
<pre>
202-
var MyController = function($scope, dep1, dep2) {
202+
someModule.controller('MyController', ['$scope', 'dep1', 'dep2', function($scope, dep1, dep2) {
203203
...
204204
$scope.aMethod = function() {
205205
...
206206
}
207-
}
208-
MyController.$inject = ['$scope', 'dep1', 'dep2'];
207+
...
208+
}]);
209209
</pre>
210210

211+
This avoids the creation of global functions for controllers and also protects against minification.
212+
211213

212214
### Factory methods
213215

0 commit comments

Comments
 (0)