forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.formatter.boolean.html
36 lines (36 loc) · 1.63 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
31
32
33
34
35
36
<h1>angular.formatter.boolean</h1>
<div class="angular-formatter-boolean"><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>
<div class="description"><p>Use boolean formatter if you wish to store the data as boolean.</p></div>
<h2>Usage</h2>
<div class="usage"><h3>In HTML Template Binding</h3>
<div class="in-html-template-binding"><div ng:non-bindable=""><pre class="brush: js; html-script: true;"><input type="text" name="bindExpression" ng:format="boolean"></pre>
</div>
</div>
<h3>In JavaScript</h3>
<div class="in-javascript"><div ng:non-bindable=""><pre class="brush: js; html-script: true;">var userInputString = angular.formatter.boolean.format(modelValue);
var modelValue = angular.formatter.boolean.parse(userInputString);</pre>
</div>
</div>
<h3>Returns</h3>
<div class="returns"><code ng:non-bindable="">{boolean}</code>
– <p>Converts to <code>true</code> unless user enters (blank), <code>f</code>, <code>false</code>, <code>0</code>, <code>no</code>, <code>[]</code>.</p></div>
</div>
<h2>Example</h2>
<div class="example"><doc:example>
<pre class="doc-source">
Enter truthy text:
<input type="text" name="value" ng:format="boolean" value="no"/>
<input type="checkbox" name="value"/>
<pre>value={{value}}</pre>
</pre>
<pre class="doc-scenario">
it('should format boolean', function(){
expect(binding('value')).toEqual('value=false');
input('value').enter('truthy');
expect(binding('value')).toEqual('value=true');
});
</pre>
</doc:example></div>
</div>