I am getting an error in my console when i am trying to get data of an object within an object and not sure what is the correct mapping to return the array of of data that i need which is results in this case.
here is how my json file looks:
{
"count": 101,
"results": //this is an array[
object 1,
object 2,....
}
My service call:
getData(){
return this._http.get('url')
.map((res:Response) => res.json())
.catch(this.handleError);
}
My component file:
getData(){
this.service.getData().subscribe(
data => this.results = data,
error => this.errorMessage = <any>error
);
}
html:
<tr *ngFor="let item of results">
<td><a style="cursor: pointer">{{item.title}}</a></td>
</tr>