Znowman
Znowman

Reputation: 395

Angularjs syntax error

Trying to output data from an API:

{{forecast.list.rain.3h}}

Gives an error: Syntax Error: Token '.3' is an unexpected token at column 19 of the expression [forecast.list.rain.3h] starting at [.3h]. saying that .3 is the error, integers not allowed in {{....}}? This seems problematic when the data is stored like this:

rain:Object
3h:0.005

Upvotes: 0

Views: 62

Answers (1)

Michael Rose
Michael Rose

Reputation: 7820

Well you can't reference this property with dot-notation since a valid identifier may not start with a number. Use {{forecast.list.rain['3h']}} instead.

Upvotes: 2

Related Questions