Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit f2f5960

Browse files
naomiblackmhevery
authored andcommitted
docs(formatter): improvements to currency, date, filter, and formatter library
Closes #1008
1 parent 5a41f3e commit f2f5960

File tree

5 files changed

+49
-46
lines changed

5 files changed

+49
-46
lines changed

Diff for: lib/core/annotation_src.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,11 @@ abstract class DetachAware {
547547
}
548548

549549
/**
550-
* Use @[Formatter] annotation to register a new formatter. A formatter is a class
551-
* with a [call] method (a callable function).
550+
* Use the @[Formatter] class annotation to register a new formatter.
551+
*
552+
* A formatter is a pure function that performs a transformation on input data from an expression.
553+
* For more on formatters in Angular, see the documentation for the
554+
* [angular:formatter](#angular-formatter) library.
552555
*
553556
* Usage:
554557
*

Diff for: lib/formatter/currency.dart

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
part of angular.formatter_internal;
22

33
/**
4-
* Formats a number as a currency (ie $1,234.56). When no currency symbol is
5-
* provided, '$' used.
4+
* Formats a number as a currency (for example $1,234.56).
5+
*
6+
* When no currency symbol is provided, '$' is used. For more on formatters,
7+
* see the [angular:formatter](#angular-formatter) library.
68
*
79
*
810
* Usage:
@@ -16,11 +18,11 @@ class Currency implements Function {
1618
var _nfs = new Map<String, NumberFormat>();
1719

1820
/**
19-
* [value]: the value to format
20-
*
21-
* [symbol]: Symbol to use.
21+
* Format a number as a currency.
2222
*
23-
* [leading]: Symbol should be placed in front of the number
23+
* - `value`: the value to format as currency.
24+
* - `symbol`: the currency symbol to use. If no symbol is specified, `$` is used.
25+
* - `leading`: places the symbol in front of the number instead of following it.
2426
*/
2527
call(value, [symbol = r'$', leading = true]) {
2628
if (value is String) value = double.parse(value);

Diff for: lib/formatter/date.dart

+24-21
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
part of angular.formatter_internal;
22

33
/**
4-
* Formats date to a string based on the requested format.
5-
* See Dart http://api.dartlang.org/docs/releases/latest/intl/DateFormat.html
6-
* for full formating options.
7-
*
8-
* - `medium`: equivalent to `MMM d, y h:mm:ss a` for en_US locale (e.g. Sep 3, 2010 12:05:08 pm)
9-
* - `short`: equivalent to `M/d/yy h:mm a` for en_US locale (e.g. 9/3/10 12:05 pm)
10-
* - `fullDate`: equivalent to `EEEE, MMMM d, y` for en_US locale (e.g. Friday, September 3, 2010)
11-
* - `longDate`: equivalent to `MMMM d, y` for en_US locale (e.g. September 3, 2010)
12-
* - `mediumDate`: equivalent to `MMM d, y` for en_US locale (e.g. Sep 3, 2010)
13-
* - `shortDate`: equivalent to `M/d/yy` for en_US locale (e.g. 9/3/10)
14-
* - `mediumTime`: equivalent to `h:mm:ss a` for en_US locale (e.g. 12:05:08 pm)
15-
* - `shortTime`: equivalent to `h:mm a` for en_US locale (e.g. 12:05 pm)
16-
*
4+
* Formats a date value to a string based on the requested format.
175
*
186
* Usage:
197
*
208
* {{ date_expression | date[:format] }}
219
*
10+
* Here `format` may be specified explicitly, or by using one of the following predefined
11+
* localizable names:
12+
*
13+
* FORMAT NAME AS DEFINED FOR en_US OUTPUT
14+
* ------------- ---------------------- ---------------------------
15+
* medium MMM d, y h:mm:ss a Sep 3, 2010 12:05:08 pm
16+
* short M/d/yy h:mm a 9/3/10 12:05 pm
17+
* fullDate EEEE, MMMM d, y Friday, September 3, 2010
18+
* longDate MMMM d, y September 3, 2010
19+
* mediumDate MMM d, y Sep 3, 2010
20+
* shortDate M/d/yy 9/3/10
21+
* mediumTime h:mm:ss a 12:05:08 pm
22+
* shortTime h:mm a 12:05 pm
23+
*
24+
*
25+
* For more on explicit formatting of dates and date syntax, see the documentation for the
26+
* [DartFormat class](http://api.dartlang.org/docs/releases/latest/intl/DateFormat.html).
27+
*
2228
*/
2329
@Formatter(name:'date')
2430
class Date implements Function {
@@ -36,15 +42,12 @@ class Date implements Function {
3642
var _dfs = new Map<String, Map<String, DateFormat>>();
3743

3844
/**
39-
* [date]: Date to format either as Date object, milliseconds
40-
* ([string] or [num]) or various ISO 8601 datetime string formats
41-
* (e.g. `yyyy-MM-ddTHH:mm:ss.SSSZ` and its shorter versions like
42-
* `yyyy-MM-ddTHH:mmZ`, `yyyy-MM-dd` or `yyyyMMddTHHmmssZ`). If no
43-
* timezone is specified in the string input, the time is considered to
44-
* be in the local timezone.
45+
* Format a value as a date.
4546
*
46-
* [format]: Formatting rules (see Description). If not specified,
47-
* mediumDate is used
47+
* - `date`: value to format as a date. If no timezone is specified in the string input,
48+
* the time is considered to be in the local timezone.
49+
* - `format`: Either a named format, or an explicit format specification. If no format is
50+
* specified, mediumDate is used.
4851
*
4952
*/
5053
dynamic call(Object date, [String format = 'mediumDate']) {

Diff for: lib/formatter/filter.dart

+10-16
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,35 @@ typedef bool _Equals(a, b);
88
* Selects a subset of items from the provided [List] and returns it as a new
99
* [List].
1010
*
11-
* In addition to the input list (implicit in an Angular expression syntax),
12-
* this formatter takes 1 required and 1 optional parameter.  They are:
11+
* Usage:
1312
*
14-
* - `expression` (required) - one of [Map], [Function], [String], [bool], [num]
15-
* - `comparator` (optional)
13+
* <div ng-repeat="item in items | filter:_expression_[:_comparator_]">
1614
*
17-
* <br>
15+
* In addition to the `expression`, which is used to select a subset from the list,
16+
* you can also specify a `comparator` to specify how the operation is performed. 
1817
*
19-
* # expression
2018
*
21-
* can be one of:
19+
* `expression` can be of the following types:
2220
*
23-
* - [String], [bool] and [num]:  Only items in the List that directly
21+
* - [String], [bool] and [num]:  Only items in the list that directly
2422
* match this expression, items that are Maps with any value matching this
25-
* item and items that are Lists containing a matching items are returned.
23+
* item, and items that are lists containing a matching items are returned.
2624
*
2725
* - [Map]:  This defines a pattern map.  Filters specific properties on objects
28-
* contained in the input List.  For example `{name:"M", phone:"1"}` predicate
26+
* contained in the input list.  For example `{name:"M", phone:"1"}` predicate
2927
* will return a list of items which have property `name` containing "M" and
3028
* property `phone` containing "1".  A special property name, `$`, can be used
3129
* (as in `{$: "text"}`) to accept a match against any property of the object.
3230
* That's equivalent to the simple substring match with a `String` as
3331
* described above.
3432
*
35-
* - [Function]:  This allows you to supply a custom function to formatter the
33+
* - [Function]:  This allows you to supply a custom function to filter the
3634
* List.  The function is called for each element of the List.  The returned
3735
* List contains exactly those elements for which this function returned
3836
* `true`.
3937
*
40-
* <br>
4138
*
42-
* # comparator
43-
*
44-
* can be one of:
39+
* `comparator` is optional and can be one of the following:
4540
*
4641
* - `bool comparator(expected, actual)`:  The function will be called with the
4742
* object value and the predicate value to compare and should return true if
@@ -55,7 +50,6 @@ typedef bool _Equals(a, b);
5550
*
5651
* - `false|null`:  Specifies case insensitive substring matching.
5752
*
58-
* <br>
5953
*
6054
* # Example ([view in plunker](http://plnkr.co/edit/6Mxz6r?p=info)):
6155
*

Diff for: lib/formatter/module.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*
66
* This library is included as part of [angular.dart](#angular/angular). It provides all of
77
* the core formatters available in Angular. You can extend Angular by writing your own formatters
8-
* and providing them as part of a custom library.
8+
* and providing them as part of a custom library. See the @[Formatter](#angular-core-annotation
9+
* .Formatter) class annotation for more detail.
910
*
1011
* Formatters are typically used within `{{ }}` to
1112
* convert data to human-readable form. They may also be used inside repeaters to transform arrays.

0 commit comments

Comments
 (0)