aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/guide/dev_guide.expressions.ngdoc
diff options
context:
space:
mode:
authorVojta Jina2011-11-29 21:51:59 -0800
committerVojta Jina2012-01-23 11:05:36 -0800
commit992c790f0786fa45c1cc3710f29bf49c7c322ba7 (patch)
tree581d06ea9ba275a14d5891d83b2df03f9930bd45 /docs/content/guide/dev_guide.expressions.ngdoc
parentf5343c9fd3c7cd0fefdb4d71d2b579dbae998d6a (diff)
downloadangular.js-992c790f0786fa45c1cc3710f29bf49c7c322ba7.tar.bz2
refactor(scope): separate controller from scope
Controller is standalone object, created using "new" operator, not messed up with scope anymore. Instead, related scope is injected as $scope. See design proposal: https://docs.google.com/document/pub?id=1SsgVj17ec6tnZEX3ugsvg0rVVR11wTso5Md-RdEmC0k Closes #321 Closes #425 Breaks controller methods are not exported to scope automatically Breaks Scope#$new() does not take controller as argument anymore
Diffstat (limited to 'docs/content/guide/dev_guide.expressions.ngdoc')
-rw-r--r--docs/content/guide/dev_guide.expressions.ngdoc16
1 files changed, 8 insertions, 8 deletions
diff --git a/docs/content/guide/dev_guide.expressions.ngdoc b/docs/content/guide/dev_guide.expressions.ngdoc
index 4df69d28..b7ecc521 100644
--- a/docs/content/guide/dev_guide.expressions.ngdoc
+++ b/docs/content/guide/dev_guide.expressions.ngdoc
@@ -51,14 +51,14 @@ You can try evaluating different expressions here:
<doc:example>
<doc:source>
<script>
- function Cntl2() {
- this.exprs = [];
- this.expr = '3*10|currency';
- this.addExp = function(expr) {
+ function Cntl2($scope) {
+ $scope.exprs = [];
+ $scope.expr = '3*10|currency';
+ $scope.addExp = function(expr) {
this.exprs.push(expr);
};
- this.removeExp = function(contact) {
+ $scope.removeExp = function(contact) {
for ( var i = 0, ii = this.exprs.length; i < ii; i++) {
if (contact === this.exprs[i]) {
this.exprs.splice(i, 1);
@@ -101,10 +101,10 @@ the global state (a common source of subtle bugs).
<doc:example>
<doc:source>
<script>
- function Cntl1($window){
- this.name = 'World';
+ function Cntl1($window, $scope){
+ $scope.name = 'World';
- this.greet = function() {
+ $scope.greet = function() {
($window.mockWindow || $window).alert('Hello ' + this.name);
}
}