angular/modules/angular2/src/pipes/default_pipes.ts
vsavkin 5b5d31fa9a feat(pipe): added the Pipe decorator and the pipe property to View
BREAKING CHANGE:
    Instead of configuring pipes via a Pipes object, now you can configure them by providing the pipes property to the View decorator.

    @Pipe({
      name: 'double'
    })
    class DoublePipe {
      transform(value, args) { return value * 2; }
    }

    @View({
      template: '{{ 10 | double}}'
      pipes: [DoublePipe]
    })
    class CustomComponent {}

Closes #3572
2015-08-12 00:38:40 +00:00

28 lines
800 B
TypeScript

import {AsyncPipe} from './async_pipe';
import {UpperCasePipe} from './uppercase_pipe';
import {LowerCasePipe} from './lowercase_pipe';
import {JsonPipe} from './json_pipe';
import {LimitToPipe} from './limit_to_pipe';
import {DatePipe} from './date_pipe';
import {DecimalPipe, PercentPipe, CurrencyPipe} from './number_pipe';
import {CONST_EXPR} from 'angular2/src/facade/lang';
import {Binding, OpaqueToken} from 'angular2/di';
const DEFAULT_PIPES_LIST = CONST_EXPR([
AsyncPipe,
UpperCasePipe,
LowerCasePipe,
JsonPipe,
LimitToPipe,
DecimalPipe,
PercentPipe,
CurrencyPipe,
DatePipe
]);
export const DEFAULT_PIPES_TOKEN = CONST_EXPR(new OpaqueToken("Default Pipes"));
export const DEFAULT_PIPES =
CONST_EXPR(new Binding(DEFAULT_PIPES_TOKEN, {toValue: DEFAULT_PIPES_LIST}));