Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/pkg/angular/lib/formatter/number.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular.filter; 1 part of angular.formatter_internal;
2 2
3 /** 3 /**
4 * Formats a number as text. 4 * Formats a number as text.
5 * 5 *
6 * If the input is not a number an empty string is returned. 6 * If the input is not a number an empty string is returned.
7 * 7 *
8 * 8 *
9 * Usage: 9 * Usage:
10 * 10 *
11 * {{ number_expression | number[:fractionSize] }} 11 * {{ number_expression | number[:fractionSize] }}
12 * 12 *
13 */ 13 */
14 @NgFilter(name:'number') 14 @Formatter(name:'number')
15 class NumberFilter { 15 class Number {
16 16
17 Map<num, NumberFormat> nfs = new Map<num, NumberFormat>(); 17 var _nfs = new Map<String, Map<num, NumberFormat>>();
18 18
19 /** 19 /**
20 * [value]: the value to format 20 * [value]: the value to format
21 * 21 *
22 * [fractionSize]: Number of decimal places to round the number to. If this 22 * [fractionSize]: Number of decimal places to round the number to. If this
23 * is not provided then the fraction size is computed from the current 23 * is not provided then the fraction size is computed from the current
24 * locale's number formatting pattern. In the case of the default locale, 24 * locale's number formatting pattern. In the case of the default locale,
25 * it will be 3. 25 * it will be 3.
26 */ 26 */
27 call(value, [fractionSize = null]) { 27 call(value, [fractionSize = null]) {
28 if (value is String) value = double.parse(value); 28 if (value is String) value = double.parse(value);
29 if (!(value is num)) return value; 29 if (!(value is num)) return value;
30 if (value.isNaN) return ''; 30 if (value.isNaN) return '';
31 var nf = nfs[fractionSize]; 31 var verifiedLocale = Intl.verifiedLocale(Intl.getCurrentLocale(), NumberForm at.localeExists);
32 _nfs.putIfAbsent(verifiedLocale, () => new Map<num, NumberFormat>());
33 var nf = _nfs[verifiedLocale][fractionSize];
32 if (nf == null) { 34 if (nf == null) {
33 nf = new NumberFormat()..maximumIntegerDigits = 9; 35 nf = new NumberFormat()..maximumIntegerDigits = 9;
34 if (fractionSize != null) { 36 if (fractionSize != null) {
35 nf.minimumFractionDigits = fractionSize; 37 nf.minimumFractionDigits = fractionSize;
36 nf.maximumFractionDigits = fractionSize; 38 nf.maximumFractionDigits = fractionSize;
37 } 39 }
38 nfs[fractionSize] = nf; 40 _nfs[verifiedLocale][fractionSize] = nf;
39 } 41 }
40 return nf.format(value); 42 return nf.format(value);
41 } 43 }
42 } 44 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/formatter/module_internal.dart ('k') | third_party/pkg/angular/lib/formatter/order_by.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698