2016-06-23 09:47:54 -07:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
import {Pipe, PipeTransform} from '@angular/core';
|
|
|
|
|
2016-05-31 15:22:59 -07:00
|
|
|
import {Json} from '../facade/lang';
|
2016-04-28 17:50:03 -07:00
|
|
|
|
2015-05-18 09:24:52 -07:00
|
|
|
|
2016-06-08 16:38:52 -07:00
|
|
|
|
2015-05-18 09:24:52 -07:00
|
|
|
/**
|
2016-09-08 21:41:09 -07:00
|
|
|
* @ngModule CommonModule
|
|
|
|
* @whatItDoes Converts value into JSON string.
|
|
|
|
* @howToUse `expression | json`
|
|
|
|
* @description
|
|
|
|
*
|
|
|
|
* Converts value into string using `JSON.stringify`. Useful for debugging.
|
2015-05-18 09:24:52 -07:00
|
|
|
*
|
2015-10-19 15:37:32 +01:00
|
|
|
* ### Example
|
2016-09-08 21:41:09 -07:00
|
|
|
* {@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
|
2016-05-27 11:24:05 -07:00
|
|
|
*
|
|
|
|
* @stable
|
2015-05-18 09:24:52 -07:00
|
|
|
*/
|
2015-10-27 10:18:29 +00:00
|
|
|
@Pipe({name: 'json', pure: false})
|
2015-08-12 12:04:54 -07:00
|
|
|
export class JsonPipe implements PipeTransform {
|
2016-04-22 15:33:32 -07:00
|
|
|
transform(value: any): string { return Json.stringify(value); }
|
2015-05-18 09:24:52 -07:00
|
|
|
}
|