ViewChild(JsonEditorComponent) editor: JsonEditorComponent returns undefined
See original GitHub issue`import { Component, OnInit, Input, ViewChild } from ‘@angular/core’; import { JsonEditorComponent, JsonEditorOptions } from ‘ang-jsoneditor’;
@Component({ selector: ‘app-code-view’, templateUrl: ‘./code-view.component.html’, styleUrls: [‘./code-view.component.scss’] }) export class CodeViewComponent implements OnInit { public editorOptions: JsonEditorOptions; @ViewChild(JsonEditorComponent) editor: JsonEditorComponent;
constructor() {
this.editorOptions = new JsonEditorOptions();
console.log('editorOptions', this.editorOptions);
console.log('editor', this.editor); => UNDEFINED?
this.editor.setOptions(this.editorOptions);
}
ngOnInit() {
}
} `
@mariohmol any idea why this.editor logs as undefined? Also this this.editorOptions.ace deprecated?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Angular 2 @ViewChild annotation returns undefined
Have a page where a list of items is shown in a table, or the edit item is shown, based on the value...
Read more >Angular Json Editor - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >How to Add Dropdown/selectbox inside JSON-EDITOR in ...
Finally I got the answer, @ViewChild(JsonEditorComponent, { static: true }) editor: JsonEditorComponent; this.editorOptions = new JsonEditorOptions() this.
Read more >ViewChild - Angular
Property decorator that configures a view query. The change detector looks for the first element or the directive matching the selector in the...
Read more >jsoneditor | based tool to view , edit , format , and validate - kandi
using useRef Hook "element.current" is null inside useEffect Hook. copy icon ... @ViewChild(JsonEditorComponent, { static: true }) editor: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok I am able to log the value in ngAfterViewInit().
Any idea how can I configure the ace editor via setOptions() @mariohmol ?
There is already an ace property to be configured: https://github.com/mariohmol/ang-jsoneditor/blob/master/ang-jsoneditor/src/jsoneditor/jsoneditor.component.ts#L111