Description
Describe the bug
I've implemented the editor with the angular wrapper, and have specified functions for onChange and onChangeJSON. onChange can be bound within the template, whereas onChangeJSON cannot, so I've added it to the editorOptions object.
this.editorOptions = new JsonEditorOptions();
this.editorOptions.mode = 'tree';
this.editorOptions.onChangeJSON = this.onEditorChangeJSON.bind(this);
At runtime, the value provided in the onChangeJSON callback is the entire json object, rather than the more fine grained values suggested by the documentation. What's more, the closure context of the function is the options object, rather than the component. I've addressed that by defining the options object like so:
This results in a somewhat odd way to access the editor in the callback:
onEditorChangeJSON(json) {
const json2 = this.editor.editor.get(); // notice how the editor is now a private member of the component reference.
}
Also, the get method returns the entire json, rather than the finer grained value that had changed.
Expected behavior
onChangeJSON should behave as suggested in the json-editor documentation:
"Set a callback function triggered when the contents of the JSONEditor change. Passes the changed contents as a JSON object."
Is this a bug, an implementation issue, or something else?
Console and Error stack trace
No error.
Desktop (please complete the following information):
- OS: Windows 10
- Browser: Chrome
"@angular/core": "~8.2.2",
"ang-jsoneditor": "^1.8.2",
"jsoneditor": "^6.2.1",