I have an Angular component function which returns a string I need to show in my HTML. The function works, but the html tag generates as empty.
Function:
getTaskNameById(id: any): string {
console.log('function start; id = ' + id);
this.tasks.forEach(e => {
if (e.idTask === Number(id)) {
console.log('if statement true; name = ' + e.name);
return e.name;
}
});
return '';
}
HTML:
{{ getTaskNameById(form.value.tasks[i]) }}:
[Console log][1]
[Page look][2]
[Generated HTML][3]
[1]: https://i.sstatic.net/Pasl0.png
[2]: https://i.imgur.com/0CKhxLt.png
[3]: https://i.imgur.com/YSkJJrY.png