Sharing Top Content from the Angular-sphere.

Using Scope.$watchCollection() To Watch Functions In AngularJS

  • // Rather than watching a String value, we’re going to watch a Function.
  • In the past, I’ve looked at using the Scope.$watch() method to watch a function , as opposed to a string, in AngularJS. Watching a function gives you fine-grained control over which value is being examined.
  • // have to watch values that are accessible off of the Scope.
  • The $watchCollection() callback was triggered whenever we changed either the simple values or the object reference.
  • Our $watchCollection() function is watching an array that contains two simple values and an object value.

Read the full article, click here.


@GrosiGm: “Great article by @BenNadel – Using Scope.$watchCollection() To Watch Functions In AngularJS”


Ben Nadel demonstrates how to use the Scope.$watchCollection() method in AngularJS to watch an arbitrary array of values.


Using Scope.$watchCollection() To Watch Functions In AngularJS

Comments are closed, but trackbacks and pingbacks are open.