angular.directive.ng:watch

Work In Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

The ng:watch allows you watch a variable and then execute an evaluation on variable change.

Usage

In HTML Template Binding

<ANY ng:watch="expression">
  ...
</ANY>
  

Parameters

Example

Notice that the counter is incremented every time you change the text.

<div ng:init="counter=0" ng:watch="name: counter = counter+1"> <input type="text" name="name" value="hello"><br/> Change counter: {{counter}} Name: {{name}} </div> it('should check ng:watch', function(){ expect(using('.doc-example-live').binding('counter')).toBe('2'); using('.doc-example-live').input('name').enter('abc'); expect(using('.doc-example-live').binding('counter')).toBe('3'); });