So I got a async problem. I get a list of soccer games which of course contains 2 teams ea. I’m trying to get the team logo’s trough a seperate API call but after that call is done the view is already loaded.
(I do get the logo url’s in the console since they come in after view is loaded)
/**
* Process the data from the request.
*/
processData(data) {
for (let i = 0; i < data.length; i++) {
data[i].divider = this.addMonthDivider(data[i].date);
data[i].today = this.isDateToday(data[i].date);
data[i].logo = [];
data[i].logo[0] = this.getTeamLogo(data[i].teams[0]);
data[i].logo[1] = this.getTeamLogo(data[i].teams[1]);
}
this.games = data;
}
/**
* Get team logo
*/
getTeamLogo(teamID) {
if (teamID == '237' || teamID == '12227') {
return 'assets/img/nec.svg';
} else {
this.httpProvider
.getData('https://www.url=' + teamID)
.subscribe(
(data: object) => {
if (data[0]) {
console.log(data[0].source_url);
return data[0].source_url;
}
});
}
}
Can anyone help me?