I have a child component implemented in the parent component where I pass data to the child component. But when I try to use the array, I always get an undefined.
How can I fix this?
export class SelectionFieldComponent implements OnInit {
@Input() data: any[] = [];
constructor() { }
ngOnInit() {
console.log(this.data);
}
}
parent.component.html
<app-selection-field [data]="units"></app-selection-field>
EDIT: I see the data on the site, but also get the error.