1

I am using the following interpolation in Angular 4:

{{variable.24h_volume}}

This results in the following error:

Unexpected token '0.24' at column 5 in [{{variable.24h_volume}}] in ng:///AppModule/Component.html

What is the problem here?

Is it the property name starting with the digit?

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
Nimish David Mathew
  • 2,958
  • 6
  • 29
  • 45
  • 1
    Yes, it is the property name starting with the digit. Variables and property names cannot begin with numbers. – R. Richards Apr 14 '18 at 19:20
  • 2
    If you want to reference a property name starting with a digit or ones the property name is a digit , try ``{{variable['24h_volume']}}`` – HDJEMAI Apr 14 '18 at 19:31

1 Answers1

5

Following my comment, I'm putting this as an answer if it can help other people.

To reference a property name starting with a digit or ones the property name is a digit , we can access that property using:

{{variable['24h_volume']}}

For more on that, please look at similar answers from SO questions like:

accessing Object property name as number

What characters are valid for JavaScript variable names?

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93