Currently, I am facing an issue with my Angular 2 app where the data sometimes lags in populating, causing a page component to load before the information is ready to display. When this happens, I can manually refresh the page for the data to appear correctly, but obviously, this is not the desired behavior. To address this issue, I attempted to move the function responsible for fetching this data into the ngOnInit lifecycle hook. However, when trying to do so, my IDE flagged an error that I cannot seem to understand.
This is an excerpt from the relevant part of my current component:
export class DoctorGeneralComponent extends EventHandler implements OnInit {
@Input('doctor')
public doctor: DoctorModel;
constructor(private dialog: MdDialog) {
super();
}
ngOnInit() {
}
public getPropertyStatus(name: string): string {
return this.doctor ? this.doctor.getPropertyStatus(name) : '';
}
}
When attempting to move the "getPropertyStatus" method into the ngOnInit like this:
ngOnInit() {
public getPropertyStatus(name: string): string {
return this.doctor ? this.doctor.getPropertyStatus(name) : '';
}
...I encounter a TypeScript error stating "declaration or statement expected."
If you have any insights on what might be causing this issue and how I can successfully include this method within my ngOnInit lifecycle hook, your assistance would be greatly appreciated.