krammer krammer - 1 year ago 130
JSON Question

Parsing JSON with spaces in key name with AngularJS

I have a json which has spaces in key names.

The JSON has the following format

"my name":"krammer",
"job": "stackexchange"

While using ng-repeat to get the parameters into a list, I use the following code

{{friends.['my name']}}

But this gives an empty output. While name

gives an error.

So how can the key names with empty spaces be accessed using AngularJS ?

Answer Source

Please try this

{{friends['my name']}}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download