Skip to content
This repository has been archived by the owner on Sep 4, 2018. It is now read-only.
/ ng2-jsoneditor Public archive

*DEPRECATED* Angular 2 component for jsoneditor

Notifications You must be signed in to change notification settings

Urbansson/ng2-jsoneditor

Repository files navigation

--- DEPRICATED ---

Use typings instead:

https://github.com/typings/typings

https://github.com/DefinitelyTyped/DefinitelyTyped

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jsoneditor

ng2-jsoneditor

Simple angular 2 wrapper for jsoneditor

Usage

Install with npm

npm install --save ng2-jsoneditor

Import the editor module

import { JSONEditorModule } from 'ng2-jsoneditor';

Include it in your root module

@NgModule({
  imports: [
    ...
    JSONEditorModule,
    ...
  ]
})
export default class AppModule {}

Add the component to the template

<div>
  <json-editor [options]="editorOptions" [data]="data"></json-editor >
</div>

Create a component to set options and call methods on the jsoneditor

import { Component, ViewChild } from '@angular/core';
import { JsonEditorComponent, JsonEditorOptions } from 'ng2-jsoneditor';

@Component({
  ...
})
export class DetailComponent {
  public editorOptions: JsonEditorOptions;

  public data: any = {
    ...
  }
  
  @ViewChild(JsonEditorComponent) editor: JsonEditorComponent;
  
  constructor(...) {
    this.editorOptions = new JsonEditorOptions();
  }
  
  public setTreeMode() {
    this.editor.setMode('tree');
  }
}

See jsonmodel's api docs for more detailed usage.

If you are building with webpack you also need to add this to your webpack config due to some warnings coming from ajv see #117.

plugins: [
  new webpack.IgnorePlugin(/regenerator|nodent|js-beautify/, /ajv/),
  ...
]

About

*DEPRECATED* Angular 2 component for jsoneditor

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published