diff --git a/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.dart b/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.dart new file mode 100644 index 0000000000..2bc22b2b2a --- /dev/null +++ b/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.dart @@ -0,0 +1,2 @@ +library angular2.examples.core.pipes.ts.async_pipe; +// TODO(alxhub): Implement an example for Dart. \ No newline at end of file diff --git a/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.ts b/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.ts new file mode 100644 index 0000000000..89c8342dd7 --- /dev/null +++ b/modules/angular2/examples/core/pipes/ts/async_pipe/async_pipe_example.ts @@ -0,0 +1,56 @@ +import {Component, provide, Observable} from 'angular2/angular2'; +import {bootstrap} from 'angular2/bootstrap'; + +// #docregion AsyncPipe +@Component({ + selector: 'async-example', + template: `
Wait for it... {{promise | async}}
+ +Today is {{today | date}}
+Or if you prefer, {{today | date:'fullDate'}}
+The time is {{today | date:'jmZ'}}
+Without JSON pipe:
+{{object}}+
With JSON pipe:
+{{object | json}}+
In lowercase:
'{{value | lowercase}}'+
In uppercase:
'{{value | uppercase}}'+
e (no formatting): {{e}}
+e (3.1-5): {{e | number:'3.1-5'}}
+pi (no formatting): {{pi}}
+pi (3.5-5): {{pi | number:'3.5-5'}}
+A: {{a | percent}}
+B: {{b | percent:'4.3-5'}}
+A: {{a | currency:'USD':false}}
+B: {{b | currency:'USD':true:'4.2-2'}}
+{{str}}[0:4]: '{{str | slice:0:4}}' - output is expected to be 'abcd'
+{{str}}[4:0]: '{{str | slice:4:0}}' - output is expected to be ''
+{{str}}[-4]: '{{str | slice:-4}}' - output is expected to be 'ghij'
+{{str}}[-4:-2]: '{{str | slice:-4:-2}}' - output is expected to be 'gh'
+{{str}}[-100]: '{{str | slice:-100}}' - output is expected to be 'abcdefghij'
+{{str}}[100]: '{{str | slice:100}}' - output is expected to be ''
+