2016-06-23 12:47:54 -04: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-08-16 14:15:01 -04:00
|
|
|
import {Component, NgModule} from '@angular/core';
|
|
|
|
import {BrowserModule} from '@angular/platform-browser';
|
|
|
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
2015-11-02 18:46:59 -05:00
|
|
|
|
|
|
|
// #docregion JsonPipe
|
|
|
|
@Component({
|
|
|
|
selector: 'json-example',
|
|
|
|
template: `<div>
|
|
|
|
<p>Without JSON pipe:</p>
|
|
|
|
<pre>{{object}}</pre>
|
|
|
|
<p>With JSON pipe:</p>
|
|
|
|
<pre>{{object | json}}</pre>
|
|
|
|
</div>`
|
|
|
|
})
|
|
|
|
export class JsonPipeExample {
|
2016-05-26 16:33:53 -04:00
|
|
|
object: Object = {foo: 'bar', baz: 'qux', nested: {xyz: 3, numbers: [1, 2, 3, 4, 5]}};
|
2015-11-02 18:46:59 -05:00
|
|
|
}
|
|
|
|
// #enddocregion
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'example-app',
|
2015-12-10 11:28:29 -05:00
|
|
|
template: `
|
2015-11-02 18:46:59 -05:00
|
|
|
<h1>JsonPipe Example</h1>
|
|
|
|
<json-example></json-example>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
export class AppCmp {
|
|
|
|
}
|
|
|
|
|
2016-08-16 14:15:01 -04:00
|
|
|
@NgModule({imports: [BrowserModule], bootstrap: [AppCmp], declarations: [AppCmp, JsonPipeExample]})
|
|
|
|
class AppModule {
|
2015-11-02 18:46:59 -05:00
|
|
|
}
|
2016-08-16 14:15:01 -04:00
|
|
|
|
|
|
|
export function main() {
|
|
|
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
2016-08-19 15:51:01 -04:00
|
|
|
}
|