hivivo/ngx-json-viewer

Not refreshing when data cames from a parent component

arcovoltaico opened this issue · 0 comments

Hi,
It happens on v2.4.0 and v3.0.2

My parent component triggers every change.
this.reloadJson.next(mydata);
and the template is
<app-json-view [data]="mydata" [reload]="reloadJson.asObservable()"> </app-json-view>

The children component gets the new data on the console (init) but it does not update the view.

<ngx-json-viewer #viewer [json]="data" [expanded]="true"></ngx-json-viewer>


export class JsonViewComponent implements OnInit {

  @Input() data;
  @Input() reload: Observable<any>;
  @ViewChild('viewer', {}) viewer: ElementRef;

  private eventsSubscription: Subscription;

  ngOnInit() {
    if (this.reload) {
      this.eventsSubscription = this.reload.subscribe((data) => this.init(data));
    }
  }

  init(data) {
    console.log(data);
    this.data = data
  }

}