Skip to content
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

Not refreshing when data cames from a parent component #63

Open
arcovoltaico opened this issue Jun 29, 2021 · 0 comments
Open

Not refreshing when data cames from a parent component #63

arcovoltaico opened this issue Jun 29, 2021 · 0 comments

Comments

@arcovoltaico
Copy link

arcovoltaico commented Jun 29, 2021

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
  }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant