-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we bind [(ngModel)] to JsonEditor ? #12
Comments
You need to bind the change method.. remember? https://github.com/mariohmol/ang-jsoneditor/blob/master/src/app/demo/demo.component.ts#L49 |
Cannot use this seems necessary if the ui has multiple (not certain count) editors. |
@mariohmol first: thank you for this library! I got to this thread trying to see if I could use two-way databinding. I've been using this component for quite a few years already, both in jQuery, AngularJS and your Angular version and I always remembered that two-way databinding was 'a thing'...
I don't really remember... Can you explain why it is not possible to use two-way binding? |
Hi!! If u can ask in there if is any news!! Thanks! |
In this editor in order to get the changed data in editor we are using onChange method detection. Instead, Can we use angular's [(ngModel)] (Two way binding ) so that we will not need to hit onChange method.
Following is my code with the OnChange method in component.ts file:
`
public editorOptions: JsonEditorOptions;
@ViewChild(JsonEditorComponent) editor: JsonEditorComponent;
Inside the template we are using as follows :
"<div class="jsoneditor-wrapper" [ngClass]="cssClass">
<json-editor
[options]="editorOptions"
[data]="data">
"
The issue is getting occurred very first time without making any change to editor, we are going to fetch the data which already has JSON object, but because change event is not detected by the jsoneditor it is giving me undefined value while doing editor.getText() method. For this reason it will be great if we use Angular's Two way binding approach.
The text was updated successfully, but these errors were encountered: