I am trying to access a JSON key value( with space) inside a HTML attribute. My page is on Angular 10 version and I am binding src attribute to a key in JSON.
<td mat-cell *matCellDef="let element">
<img [src]="element.Player Name"/>
</td>
JSON
{
"Name": "Richard",
"Player Name": "https://sampleURl/example.jpg"
}
Here 'Player Name' is the key with space. I tried:
<td mat-cell *matCellDef="let element">
<img [src]="element[Player Name]"/>
</td>
This works for normal binding but not here. Thanks for any help
element['Player Name']works.element.Player_Namemay also be worth a try.