forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.filter.currency.html
47 lines (46 loc) · 1.37 KB
/
angular.filter.currency.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.filter.currency</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>Formats a number as a currency (ie $1,234.56).</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<span>{{</span>
amount_expression
| currency<span> }}</span>
</tt>
<h3>In JavaScript</h3>
<tt ng:non-bindable>
angular.filter.currency(amount);
</tt>
<h3>Parameters</h3>
<ul>
<li><tt>amount</tt> –
<tt>{number}</tt>
<tt></tt>
– Input to filter.</li>
</ul>
<h3>Returns</h3>
<tt>{string}</tt> Formated number.
<h3>CSS</h3>
ng-format-negative
When the value is negative, this css class is applied to the binding making it by default red.
<h2>Example</h2>
<doc:example>
<doc:source>
<input type="text" name="amount" value="1234.56"/> <br/>
{{amount | currency}}
</doc:source>
<doc:scenario> it('should init with 1234.56', function(){
expect(binding('amount | currency')).toBe('$1,234.56');
});
it('should update', function(){
input('amount').enter('-1234');
expect(binding('amount | currency')).toBe('$-1,234.00');
expect(element('.doc-example-live .ng-binding').attr('className')).
toMatch(/ng-format-negative/);
});</doc:scenario>
</doc:example>