Hello,
I’m pulling in a record from the database and trying to display the record without running it through *ngFor as its only one record returned.
I confirmed the data is returned by {{userDetails | json}}.
I can display the array via *ngFor but its just a record so there’s no need to loop through the record using *ngfor.
I tried {{userDetails.firstname}}, {{userDetails[0].firstname}}, and {{userDetails?.firstname}} nothing seems to be working.
what am i missing?
The funny thing is that the component script and the service script are basically a copy/past from one of my working script so im lost as to what is this I’m missing.
any help you can provide would be greatly appreciated
the error message received:
EXCEPTION: Uncaught (in promise): Error: Error in ../app/userporting/user-details.component.html:6:53 caused by: Cannot read property 'firstname' of undefined
Error: Error in ../app/userporting/user-details.component.html:6:53 caused by: Cannot read property 'firstname' of undefined
array format is:
[ { "firstname": "Mike", "lastname": "smith", "age": "29-Mar-78" } ]
component
this.getInfService.getUserMethod(this.userID)
.subscribe(data => this.userDetails = data);
Service
return this._http.post(this.usrQueryURL, getUserInfo, options )
.map((res: Response) => res.json())
.catch(error => <any>error);