diff options
| author | Igor Minar | 2012-06-10 09:01:42 -0700 | 
|---|---|---|
| committer | Igor Minar | 2012-06-10 09:01:42 -0700 | 
| commit | 5d70e4a89cd9b3d430bb81f438cf03e956d9a9d2 (patch) | |
| tree | 2a9311d9735c938321e581b22fb3e06c40839385 /docs/content/guide | |
| parent | b5bba65a9353ca9dc03b8d0c3c9b06d9c4cdacdf (diff) | |
| download | angular.js-5d70e4a89cd9b3d430bb81f438cf03e956d9a9d2.tar.bz2 | |
docs(*): fix various outdated docs and examples
Closes #1030
Diffstat (limited to 'docs/content/guide')
4 files changed, 17 insertions, 23 deletions
diff --git a/docs/content/guide/dev_guide.services.$location.ngdoc b/docs/content/guide/dev_guide.services.$location.ngdoc index c5396b11..209b3abc 100644 --- a/docs/content/guide/dev_guide.services.$location.ngdoc +++ b/docs/content/guide/dev_guide.services.$location.ngdoc @@ -622,11 +622,11 @@ example:  </pre>  <pre>  // js - controller -this.$watch('locationPath', function(path) { +$scope.$watch('locationPath', function(path) {    $location.path(path);  }); -this.$watch('$location.path()', function(path) { +$scope.$watch('$location.path()', function(path) {    scope.locationPath = path;  });  </pre> diff --git a/docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc b/docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc index 9ec6fdab..b21e6f0c 100644 --- a/docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc +++ b/docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc @@ -2,16 +2,10 @@  @name Developer Guide: Templates: Filters: Creating Angular Filters  @description -Writing your own filter is very easy: just define a JavaScript function on the `angular.module.ng.$filter` -object. -The framework passes in the input value as the first argument to your function. Any filter -arguments are passed in as additional function arguments. - -You can use these variables in the function: - -* `this` — The current scope. -* `this.$element` — The DOM element containing the binding. The `$element` variable allows the -filter to manipulate the DOM. +Writing your own filter is very easy: just register a new filter (injectable) factory function with +your module. This factory function should return a new filter function which takes the input value +as the first argument. Any filter arguments are passed in as additional arguments to the filter +function.  The following sample filter reverses a text string. In addition, it conditionally makes the  text upper-case and assigns color. diff --git a/docs/content/guide/dev_guide.unit-testing.ngdoc b/docs/content/guide/dev_guide.unit-testing.ngdoc index f9e148eb..2083f2e4 100644 --- a/docs/content/guide/dev_guide.unit-testing.ngdoc +++ b/docs/content/guide/dev_guide.unit-testing.ngdoc @@ -218,16 +218,16 @@ In angular the controllers are strictly separated from the DOM manipulation logi  a much easier testability story as can be seen in this example:  <pre> -function PasswordCntrl() { -  this.password = ''; -  this.grade = function() { -    var size = this.password.length; +function PasswordCntrl($scope) { +  $scope.password = ''; +  $scope.grade = function() { +    var size = $scope.password.length;      if (size > 8) { -      this.strength = 'strong'; +      $scope.strength = 'strong';      } else if (size > 3) { -      this.strength = 'medium'; +      $scope.strength = 'medium';      } else { -      this.strength = 'weak'; +      $scope.strength = 'weak';      }    };  } diff --git a/docs/content/guide/expression.ngdoc b/docs/content/guide/expression.ngdoc index f92dbe48..28edcc22 100644 --- a/docs/content/guide/expression.ngdoc +++ b/docs/content/guide/expression.ngdoc @@ -55,14 +55,14 @@ You can try evaluating different expressions here:  <doc:source>   <script>     function Cntl2($scope) { -     $scope.exprs = []; +     var exprs = $scope.exprs = [];       $scope.expr = '3*10|currency';       $scope.addExp = function(expr) { -        this.exprs.push(expr); +        exprs.push(expr);       };       $scope.removeExp = function(index) { -       this.exprs.splice(index, 1); +       exprs.splice(index, 1);       };     }   </script> @@ -104,7 +104,7 @@ prevent accidental access to the global state (a common source of subtle bugs).       $scope.name = 'World';       $scope.greet = function() { -       ($window.mockWindow || $window).alert('Hello ' + this.name); +       ($window.mockWindow || $window).alert('Hello ' + $scope.name);       }     }   </script>  | 
