In my child.component I have a serivce call that returns an array of objects, invoiceRes, and I assign it to a global variable. Looks like this:
invoiceCases;
this.casesService.getCaseByInvoice(invoice.invoiceNumber)
.subscribe(invoiceRes => {
this.invoiceCases = invoiceRes;
},
err => {
console.log(err);
})
In my parent component I am trying to catch the update of this variable with ngOnChange(), which looks like:
@Input() invoiceCases;
ngOnChanges(event) {
if (event.invoiceCases) {
this.casesCheck();
}
}
However ngOnChange is not catching that invoiceCases is assigned the array from the response on the service call.
Any help would be much appreciated.
@Inputis used to communicate from parent to child, not the other way around Either u use service or@output