We have a data object stored on our server structured like this;
{
"NFL": {
"link": "https://www.nfl.com/",
"ticketPrice": 75
},
"MLB": {
"link": "https://www.mlb.com/",
"ticketPrice": 60
},
"NHL": {
"link": "https://www.nhl.com/",
"ticketPrice": 55
},
"MLS": {
"link": "https://www.mlssoccer.com/",
"ticketPrice": 45
}
}
To access this object, I have subscribed to it using the following code;
sportsObject : Sports[] //THIS IS THE MEMBER THAT SHOULD BE FILLED WITH THE JSON OBJECT GIVEN
object = Object;
ngOnInit(){
this.SportsService.getPrices().subscribe(data=>{
this.sportsObject = data;
})
}
Below is my html code for displaying the data;
<div *ngFor="let key of Object.keys(sportsObject)">
<p>The {{key}} is {{{{sportsObject[key]}}</p>
</div>
However, I am encountering the error message, "Cannot find a differ supporting object '[object Object]' of type 'object'." How can I rectify this issue and successfully iterate through this JSON object?