Angular 2 – Passing data to Child component after Parent initialisation

Since data is undefined at start, you can postpone it with *ngIf=”data”

<div *ngIf="data">
   <test-child [childData]="data"></test-child>
</div>

Or you can implement ControlValueAccessor on your component and pass it by ngModel with ngModelChange

<test-child [ngModel]="data?" (ngModelChange)="data? ? data= $event : null"></test-child>

Leave a Comment