'Why does a proprety call {{hero.name}} work in a <h> but not in a <img>

In the template, the following code works normally:

<h3>{{hero.name}}</h3>

or even:

<a routerLink="/details/{{hero.id}}">{{hero.name}}</a>

But when it comes to the following image path:

<img [src]="'/pictures/{{hero.name}}' | getDownloadURL" />

It is interpreted as a string, as in the error message:

ERROR FirebaseError: Firebase Storage: Object 'pictures/{{hero.name}}' does not exist. (storage/object-not-found)

Even though the picture is accessible through:

<img [src]="'/pictures/mario' | getDownloadURL" />


Solution 1:[1]

Try this

<img [src]="'/pictures/' + hero.name | getDownloadURL" />

Solution 2:[2]

Use template strings in such cases: /pictures/${hero.name} | getDownloadURL

Solution 3:[3]

try to use `` quotes

"`/pictures/{{hero.name}} | getDownloadURL"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Luís Filipe Vaz
Solution 2 Sana M.
Solution 3 Pete Pearl