diff options
author | Amir H. Hajizamani | 2013-01-14 19:34:00 +0000 |
---|---|---|
committer | Brian Ford | 2013-01-18 00:49:41 -0500 |
commit | 75487ec933fb82702eeb0c65bd5f13ad9f07fbaf (patch) | |
tree | a674410784eb553135fbd9f80bff637112029189 /docs/content/guide/di.ngdoc | |
parent | dddb1221faa31b4942131ec6e8adfefb9af470d3 (diff) | |
download | angular.js-75487ec933fb82702eeb0c65bd5f13ad9f07fbaf.tar.bz2 |
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.
Diffstat (limited to 'docs/content/guide/di.ngdoc')
-rw-r--r-- | docs/content/guide/di.ngdoc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/docs/content/guide/di.ngdoc b/docs/content/guide/di.ngdoc index a9280103..75d016b6 100644 --- a/docs/content/guide/di.ngdoc +++ b/docs/content/guide/di.ngdoc @@ -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> |