Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

docs(Scope): clarify naming in the $watch example #8271

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/ng/rootScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ function $RootScopeProvider(){
* can compare the `newVal` and `oldVal`. If these two values are identical (`===`) then the
* listener was called due to initialization.
*
* The example below contains an illustration of using a function as your $watch listener
*
*
* # Example
Expand Down Expand Up @@ -278,14 +277,14 @@ function $RootScopeProvider(){



// Using a listener function
// Using a function as a watchExpression
var food;
scope.foodCounter = 0;
expect(scope.foodCounter).toEqual(0);
scope.$watch(
// This is the listener function
// This is the function that returns a value to be watched. It is called for each turn of the $digest loop
function() { return food; },
// This is the change handler
// This is the change listener, called when the value returned from the above function changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally, this function is sometimes called the watchAction, but change listener makes sense in this example.

function(newValue, oldValue) {
if ( newValue !== oldValue ) {
// Only increment the counter if the value changed
Expand Down