gdi2290 e77710a372 fix(JsonPipe): always transform to json
BREAKING CHANGE:

no longer cache ref
2015-06-08 16:22:04 -07:00

36 lines
689 B
TypeScript

import {isBlank, isPresent, Json} from 'angular2/src/facade/lang';
import {Pipe, PipeFactory} from './pipe';
/**
* Implements json transforms to any object.
*
* # Example
*
* In this example we transform the user object to json.
*
* ```
* @Component({
* selector: "user-cmp"
* })
* @View({
* template: "User: {{ user | json }}"
* })
* class Username {
* user:Object
* constructor() {
* this.user = { name: "PatrickJS" };
* }
* }
*
* ```
*
* @exportedAs angular2/pipes
*/
export class JsonPipe extends Pipe {
supports(obj): boolean { return true; }
transform(value): string { return Json.stringify(value); }
create(cdRef): Pipe { return this }
}