0

Hey i am trying to parse with ngFor some data from an array to my html but on my last mapping the key is called "24hVolume"

<tbody *ngFor="let coin of cryptoCoins; let i = index">
  <tr>
    <th>{{ i + 1 }}</th>
    <td>
      <img
        height="32"
        width="32"
        src="{{ coin.iconUrl }}"
        alt="{{ coin.name }}"
      />
    </td>
    <td>{{ coin.name }}</td>
    <td>{{ coin.symbol }}</td>
    <td>{{ coin.price }}</td>
    <td>{{ coin.marketCap }}</td>
    <td>{{ coin.24hVolume }}</td>
  </tr>
</tbody>

so angular is complaining with: Parser Error: Expected identifier for property access at the end of the expression [{{ coin."24H" }}]

seems like string interpolation doesn't understand that i am calling a string value. Do i have to cast the key? Or what is the best solution ?

Thanks for your answers.

Mario Petrovic
  • 7,500
  • 14
  • 42
  • 62
Atropos
  • 13
  • 1
  • 5
  • Does this answer your question? [Angular Interpolation of property name starting with digit](https://stackoverflow.com/questions/49835169/angular-interpolation-of-property-name-starting-with-digit) – serrulien Nov 11 '21 at 01:30

1 Answers1

1

Did you try to access it with brackets?, <td>{{ coin['24hVolume'] }}</td>

Alejandro Barone
  • 1,743
  • 2
  • 13
  • 24