forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.formatter.boolean.html
30 lines (30 loc) · 1.04 KB
/
angular.formatter.boolean.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
<h1>angular.formatter.boolean</h1>
<h2>Description</h2>
<p>Use boolean formatter if you wish to store the data as boolean.</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<input type="text" ng:format="boolean">
</tt>
<h3>In JavaScript</h3>
<tt ng:non-bindable>
var userInputString = angular.formatter.boolean.format(modelValue);<br/>
var modelValue = angular.formatter.boolean.parse(userInputString);
</tt>
<h3>Returns</h3>
<p>Convert to <code>true</code> unless user enters (blank), <code>f</code>, <code>false</code>, <code>0</code>, <code>no</code>, <code>[]</code>.</p>
<h3>CSS</h3>
<h2>Example</h2>
<doc:example>
<doc:source>
Enter truthy text:
<input type="text" name="value" ng:format="boolean" value="no"/>
<input type="checkbox" name="value"/>
<pre>value={{value}}</pre>
</doc:source>
<doc:scenario>it('should format boolean', function(){
expect(binding('value')).toEqual('value=false');
input('value').enter('truthy');
expect(binding('value')).toEqual('value=true');
});</doc:scenario>
</doc:example>