3

I have tab content that relies on data that is updated in the parent component. When I change tabs, I calculate the new data and then the child renders with the new data. However I am surprised to find that the child component initialises before the tab change is processed, and so it renders with the old data. I have been forced to add a 10ms delay during initialisation of the child so the correct new data can arrive. I've tried ngOnInit() and ngAfterViewInit() and they both fire before the MatTabChangeEvent.

What is the right way to update data on mat-tab-group selectedTabChange() so it happens before the mat-tab child initialises?

mikeyc7m
  • 73
  • 7

1 Answers1

0

You can try with (focusChange)="update()". Here it is mentioned for checking a condition on tab change: Using mat-tab-group focusChange event, How to stop user navigating to other tab

DMinovski
  • 61
  • 2
  • 2
  • 7