tree: 394a2d07f2aedbea37d21a72a58f21570ad5dcc5 [path history] [tgz]
  1. _json-formatter-theme.scss
  2. covalent-core-json-formatter.d.ts
  3. covalent-core-json-formatter.metadata.json
  4. index.d.ts
  5. json-formatter.component.d.ts
  6. json-formatter.component.scss
  7. json-formatter.module.d.ts
  8. package.json
  9. public-api.d.ts
  10. README.md
node_modules/@covalent/core/json-formatter/README.md

td-json-formatter

td-json-formatter renders a javascript object in JSON format the same way the chrome/firefox console would render it using console.log().

Hovering on nodes will bring out a preview tooltip of the first 5 objects/properties of the node.

The tree is collapsable/expandable so you can navigate through its nodes.

API Summary

Inputs

  • key?: string
    • Tag to be displayed as root of formatted object.
  • data: any
    • JS object to be formatted.
  • levelsOpen?: number
    • Levels opened by default when JS object is formatted and rendered.

Methods

  • refresh: function
    • Refreshes json-formatter and rerenders [data]

Setup

Import the [CovalentJsonFormatterModule] in your NgModule:

import { CovalentJsonFormatterModule } from '@covalent/core/json-formatter';
@NgModule({
  imports: [
    CovalentJsonFormatterModule,
    ...
  ],
  ...
})
export class MyModule {}

Usage

Simply add the component and pass the object to be formatted as a [data] input.

Example for HTML usage:

<td-json-formatter [data]="object" key="root" [levelsOpen]="1">
</td-json-formatter>