mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-21 18:42:31 +08:00
docs(guide): change prototype methods to scope methods in DI examples
As explained in 'Understanding the Controller Component', Controllers written for new (post 1.0 RC) versions of Angular need to add methods to the scope directly, not the function's prototype. Correcting this example should remove any ambiguity, especially for beginners.
This commit is contained in:
committed by
Brian Ford
parent
f179a63dd4
commit
6e8728a364
@@ -196,14 +196,13 @@ Controllers are classes which are responsible for application behavior. The reco
|
||||
declaring controllers is:
|
||||
|
||||
<pre>
|
||||
var MyController = function(dep1, dep2) {
|
||||
...
|
||||
}
|
||||
MyController.$inject = ['dep1', 'dep2'];
|
||||
|
||||
MyController.prototype.aMethod = function() {
|
||||
var MyController = function($scope, dep1, dep2) {
|
||||
...
|
||||
$scope.aMethod = function() {
|
||||
...
|
||||
}
|
||||
}
|
||||
MyController.$inject = ['$scope', 'dep1', 'dep2'];
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user