rodikh/angular-json-editor

How to get an instance of the current editor in order to set and get values from it?

cesarvega opened this issue · 1 comments

Hi, I was wondering if you know how to get an instance of the current editor so I can use the methods
editor.getValue();
editor.setValue({
name: "John Smith"
}); ?

You need to pass a buttonsController in order to gain access to the editor object.
see the example:
https://github.com/rodikh/angular-json-editor/blob/master/demo/app.js#L51
https://github.com/rodikh/angular-json-editor/blob/master/demo/index.html#L19
This will allow you to access it using $scope.editor.setValue/getValue

Otherwise, you can use the onChange method to get the form's value whenever it's changed, but not to set the value at any time.