doc: add some API doc

Closes #4060
This commit is contained in:
Victor Berchet
2015-09-03 16:17:23 -07:00
parent 5e013c4aef
commit 998c7c2e03
9 changed files with 164 additions and 33 deletions

View File

@ -1,17 +1,38 @@
import {ABSTRACT, BaseException, CONST, Type} from 'angular2/src/core/facade/lang';
/**
* An interface which all pipes must implement.
* To create a Pipe, you must implement this interface.
*
* #Example
* Angular invokes the `transform` method with the subject as the `value` argument and any
* parameters in the `args` Array.
*
* ## Syntax
*
* `subject | pipeName[:arg0[:arg1...]]`
*
* ## Example
*
* The `RepeatPipe` below repeats the subject as many times as indicated by the first argument:
*
* ```
* class DoublePipe implements PipeTransform {
* transform(value, args = []) {
* return `${value}${value}`;
* @Pipe({name: 'repeat'})
* class RepeatPipe implements PipeTransform {
*
* transform(value: any, args: any[] = []) {
* if (isBlank(args) || args.length == 0) {
* throw new BaseException('limitTo pipe requires one argument');
* }
*
* let times: number = args[0];
*
* return value.repeat(times);
* }
* }
* ```
*
* Invoking `{{ 'ok' | repeat:3 }}` in a template produces `okokok`.
*
* ```
*/
export interface PipeTransform { transform(value: any, args: any[]): any; }