forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.directive.ng:watch.html
41 lines (40 loc) · 1.21 KB
/
angular.directive.ng:watch.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<h1>angular.directive.ng:watch</h1>
<fieldset class="workInProgress">
<legend>Work In Progress</legend>
This page is currently being revised. It might be incomplete or contain inaccuracies.
</fieldset>
<h2>Description</h2>
<p>The <code>ng:watch</code> allows you watch a variable and then execute
an evaluation on variable change.</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<pre>
<ANY ng:watch="expression">
...
</ANY>
</pre>
</tt>
<h3>Parameters</h3>
<ul>
<li><tt>expression</tt> –
<tt>{expression}</tt>
<tt></tt>
– to eval.</li>
</ul>
<h2>Example</h2>
<p>Notice that the counter is incremented
every time you change the text.</p>
<doc:example>
<doc:source>
<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>
</doc:source>
<doc:scenario> 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');
});</doc:scenario>
</doc:example>