2015-06-05 10:44:01 -07:00
|
|
|
import {isBlank, isPresent, Json} from 'angular2/src/facade/lang';
|
2015-06-18 15:40:12 -07:00
|
|
|
import {Pipe, BasePipe, PipeFactory} from './pipe';
|
2015-05-18 09:24:52 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2015-06-18 15:40:12 -07:00
|
|
|
export class JsonPipe extends BasePipe {
|
2015-06-05 10:44:01 -07:00
|
|
|
transform(value): string { return Json.stringify(value); }
|
2015-05-18 09:24:52 -07:00
|
|
|
|
2015-06-05 10:44:01 -07:00
|
|
|
create(cdRef): Pipe { return this }
|
2015-05-18 09:24:52 -07:00
|
|
|
}
|