I was working with the Tour of Heroes example on the angular site (https://angular.io/tutorial/toh-pt4) and I'm having problems with the service call resolving my page object. If I call the mocked object directly everything works fine(return MOCKEDOBJECT) but when I try to use the response I keep getting the error cannot read property of undefined. I'm very new to angular and I'm just not seeing what I'm doing wrong.
Here's the service code:
getEmployer(): Promise<Employer> {
return Promise.resolve(EMPLOYER);//doesn't work
}
getMockEmployer(): Employer {
return EMPLOYER; //works fine
}
here's what's in my page code:
//mocked promise - doesn't work
this.employerService.getEmployer().then(employer => this.employer = employer);
//mocked data - works fine.
//this.employer = this.employerService.getMockEmployer();
FYI, my npm folder has a referenced to @angular/core(4.1.2)
I'm not doing an api call yet. I'm still working with mocked data from within the service. I'm not seeing any difference between the sample that exists in Tour of Heros and my code, but theirs works and mine doesn't.