I have a function:
@Input getErrorFields(): Array<any> {
this.sharedService.getErrors().then((value => {value ? this.errorFields.push(...value) : null})
return this.errorFields;
}
My angular project is packed into a js file and integrated into a webpage. When getErrorFields is called from JavaScript code within the webpage, sharedService is undefined.
I have tried debugging to check if sharedService is initialized before the function in my component is called, and it is. Also, if getErrorFields() is called at the beginning of ngOnInit, it returns the correct value.
I have also tried binding the function due to context, but I got the same error.
billybob412 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.