aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/content/cookbook/buzz.ngdoc12
-rw-r--r--docs/content/cookbook/form.ngdoc8
-rw-r--r--docs/content/cookbook/mvc.ngdoc7
-rw-r--r--docs/content/guide/dev_guide.services.$location.ngdoc4
-rw-r--r--docs/content/guide/dev_guide.templates.filters.creating_filters.ngdoc14
-rw-r--r--docs/content/guide/dev_guide.unit-testing.ngdoc14
-rw-r--r--docs/content/guide/expression.ngdoc8
7 files changed, 31 insertions, 36 deletions
diff --git a/docs/content/cookbook/buzz.ngdoc b/docs/content/cookbook/buzz.ngdoc
index bf900223..7277f957 100644
--- a/docs/content/cookbook/buzz.ngdoc
+++ b/docs/content/cookbook/buzz.ngdoc
@@ -12,10 +12,10 @@ to retrieve Buzz activity and comments.
<doc:example>
<doc:source>
<script>
- BuzzController.$inject = ['$resource'];
- function BuzzController($resource) {
- this.userId = 'googlebuzz';
- this.Activity = $resource(
+ BuzzController.$inject = ['$scope', '$resource'];
+ function BuzzController($scope, $resource) {
+ $scope.userId = 'googlebuzz';
+ $scope.Activity = $resource(
'https://www.googleapis.com/buzz/v1/activities/:userId/:visibility/:activityId/:comments',
{alt: 'json', callback: 'JSON_CALLBACK'},
{ get: {method: 'JSONP', params: {visibility: '@self'}},
@@ -24,10 +24,10 @@ to retrieve Buzz activity and comments.
}
BuzzController.prototype = {
fetch: function() {
- this.activities = this.Activity.get({userId:this.userId});
+ $scope.activities = $scope.Activity.get({userId:this.userId});
},
expandReplies: function(activity) {
- activity.replies = this.Activity.replies({userId: this.userId, activityId: activity.id});
+ activity.replies = $scope.Activity.replies({userId: this.userId, activityId: activity.id});
}
};
</script>
diff --git a/docs/content/cookbook/form.ngdoc b/docs/content/cookbook/form.ngdoc
index f746e327..829547f4 100644
--- a/docs/content/cookbook/form.ngdoc
+++ b/docs/content/cookbook/form.ngdoc
@@ -11,7 +11,7 @@ allow a user to enter data.
<doc:source>
<script>
function FormController($scope) {
- $scope.user = {
+ var user = $scope.user = {
name: 'John Smith',
address:{line1: '123 Main St.', city:'Anytown', state:'AA', zip:'12345'},
contacts:[{type:'phone', value:'1(234) 555-1212'}]
@@ -20,12 +20,12 @@ allow a user to enter data.
$scope.zip = /^\d\d\d\d\d$/;
$scope.addContact = function() {
- $scope.user.contacts.push({type:'email', value:''});
+ user.contacts.push({type:'email', value:''});
};
$scope.removeContact = function(contact) {
- for (var i = 0, ii = this.user.contacts.length; i < ii; i++) {
- if (contact === this.user.contacts[i]) {
+ for (var i = 0, ii = user.contacts.length; i < ii; i++) {
+ if (contact === user.contacts[i]) {
$scope.user.contacts.splice(i, 1);
}
}
diff --git a/docs/content/cookbook/mvc.ngdoc b/docs/content/cookbook/mvc.ngdoc
index 92033352..da8f48e2 100644
--- a/docs/content/cookbook/mvc.ngdoc
+++ b/docs/content/cookbook/mvc.ngdoc
@@ -6,9 +6,10 @@ MVC allows for a clean an testable separation between the behavior (controller)
(HTML template). A Controller is just a JavaScript class which is grafted onto the scope of the
view. This makes it very easy for the controller and the view to share the model.
-The model is simply the controller's this. This makes it very easy to test the controller in
-isolation since one can simply instantiate the controller and test without a view, because there is
-no connection between the controller and the view.
+The model is a set of objects and primitives that are referenced from the Scope ($scope) object.
+This makes it very easy to test the controller in isolation since one can simply instantiate the
+controller and test without a view, because there is no connection between the controller and the
+view.
<doc:example>
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>