I would like to manipulate data that is passed into a child component but I can't access that variable from within the component. I can only seem to get the data from the template. Why is the data variable undefined from within the component but not the template?
Parent component template:
//messageReceived is an array of objects
<app-data-table [data]='messageReceived'>
Child component
@Input() data: any;
constructor() {console.log(this.data)} /*This DOESN'T work. this.data is undefined
ngOnInit() {
console.log(this.data) /*empty object*/
}
Child component template:
{{data | json }} <!--This DOES work-->
ngOnChanges/ngOnInitngOnChangeshook?