forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.directive.ng:change.html
47 lines (43 loc) · 1.45 KB
/
angular.directive.ng:change.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
42
43
44
45
46
47
<h1>angular.directive.ng:change</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 directive executes an expression whenever the input widget changes.</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<pre>
<INPUT ng:change="expression">
...
</INPUT>
</pre>
</tt>
<h3>Parameters</h3>
<ul>
<li><tt>expression</tt> –
<tt>{expression}</tt>
<tt></tt>
– to execute.</li>
</ul>
<h2>Example</h2>
<doc:example>
<doc:source>
<div ng:init="checkboxCount=0; textCount=0"></div>
<input type="text" name="text" ng:change="textCount = 1 + textCount">
changeCount {{textCount}}<br/>
<input type="checkbox" name="checkbox" ng:change="checkboxCount = 1 + checkboxCount">
changeCount {{checkboxCount}}<br/>
</doc:source>
<doc:scenario> it('should check ng:change', function(){
expect(binding('textCount')).toBe('0');
expect(binding('checkboxCount')).toBe('0');
using('.doc-example-live').input('text').enter('abc');
expect(binding('textCount')).toBe('1');
expect(binding('checkboxCount')).toBe('0');
using('.doc-example-live').input('checkbox').check();
expect(binding('textCount')).toBe('1');
expect(binding('checkboxCount')).toBe('1');
});</doc:scenario>
</doc:example>