1.3.4 • Published 2 years ago
ng-svelte-jsoneditor v1.3.4
ng-svelte-jsoneditor
Angular Json Editor (wrapper for svelte-jsoneditor). View/Edit Json file with formatting.
A web-based tool to view, edit, format, transform, and validate JSON.
Installation
npm install ng-svelte-jsoneditorUsage
@NgModule({
declarations: [
AppComponent
],
imports: [
......
NgSvelteJsonEditorModule
],
providers: [],
bootstrap: [AppComponent]
})<ng-svelte-jsoneditor [formControl]="editor"></ng-svelte-jsoneditor>Methods
<ng-svelte-jsoneditor [formControl]="editor" [options]="options" (onInitialized)="onInitialized($event)"></ng-svelte-jsoneditor>Use pre-defined options & methods
options: JSONEditorPropsOptional = {
onChange: (c) => {
//console.log(c);
}
};Same methods are accessible via subscription
onInitialized(eventSub: {[key: string]: Subject<any>}) {
eventSub['onChange'].subscribe((c: any) => {
});
}Supported Methods For Above
onChangeQueryLanguage
onChange
onClassName
onChangeMode
onSelect
onError
onFocus
onBlur@Inputs - methods
onRenderValue
onRenderMenu
onRenderContextMenuAccessing component reference
@ViewChild(NgSvelteJsoneditorComponent, { static: true }) ngSvelteJsoneditorComponent: NgSvelteJsoneditorComponent | undefinedDisable field
this.editor.disable()Set options
<!-- Method 1 -->
this.ngSvelteJsoneditorComponent?.setOptions(
{
mode: Mode.text
}
)
<!-- Method 2 -->
this.options.mode = Mode.text;
this.options = JSON.parse(JSON.stringify(this.options))Documentation
License
ng-svelte-jsoneditor is released as open source under the permissive the ISC license. MIT