당신이 그렇게 경사 느끼면 같아요
ngOnInit() {
this.editorOptions.modes = ['code', 'text', 'tree', 'view']; // set all allowed modes
this.payLoadData = this.jsondata[0]; // initial file read data
}
submitSequence(){
this._responseService.getPayLoadFromUrl()
.subscribe(data=>{
this.payLoadData = data;
},
error=>{
console.error(error);
})
}
<div class="inputSection">
<input type="text" placeholder="Enter sequence url">
<button (click)="submitSequence()">Submit</button>
<button (click)="generateResponse()">Generate response.json</button>
</div>
<json-editor [options]="editorOptions" [data]="payLoadData"></json-editor>
, 당신은
onChanges
을 포함하도록
package source을 편집 할 수 있습니다. 예를 들어 :
import { OnChanges, SimpleChanges } from '@angular/core';
...
export class JsonEditorComponent implements OnInit, OnChanges {
...
ngOnChanges(changes: SimpleChanges): void {
if(changes.data.firstChange) return;
this.destroy();
this.editor = new editor(this.rootElement.nativeElement, this.options, changes.data.currentValue);
}
...
}
이것은 이론적으로 할 때 payLoadData
변경 바인딩 속성을 업데이트해야합니다. (안타깝게도 지금 당장 테스트 할 방법이 없습니다.)
콘솔에 오류가 있습니까? –
아무 것도 아님. [데이터]를 새로 고치지 않기 만하면됩니다. –
이 문제는 [공개 문제] (https://github.com/manishit56/Angular4-JsonEditor/issues/6)처럼 보입니다. – Und3rTow