Nimish David Mathew
Nimish David Mathew

Reputation: 3168

Angular Interpolation of property name starting with digit

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?

Upvotes: 1

Views: 651

Answers (1)

HDJEMAI
HDJEMAI

Reputation: 9800

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?

Upvotes: 5

Related Questions