0

I am working with a trading partner who sends me JSON with embedded spaces in the keys. For example

[{"BANK ID":89769876976,"Account Number":789698769876,"Account Type":"CHECKING","Balance":1187.65...

and I cannot find a way to access the keys using angular {{ }} expressions. Any clues?

Ross
  • 1,313
  • 4
  • 16
  • 24
stanlick
  • 1,442
  • 3
  • 16
  • 29
  • possible duplicate of [Accessing JSON object keys having spaces](http://stackoverflow.com/questions/10311361/accessing-json-object-keys-having-spaces) – Julien May 01 '14 at 15:37
  • maybe you can add more context? it looks like yourvar['your key'] should be enough – Eduard Gamonal May 01 '14 at 16:00
  • I have tried {{'t.BANK ID'}} {{['t.BANK ID']}} {{t.[BANK ID]}} and {{t.['BANK ID']}} and none of them work. If I change the JSON key to BANK_ID, it works great! – stanlick May 01 '14 at 16:14

1 Answers1

4

You can just use the bracket notation (without the dot)

<div ng-repeat="acct in accounts">
  Bank Id: {{ acct['BANK ID'] }},
  Account Number: {{ acct['Account Number'] }}, 
  Type: {{ acct['Account Type'] }},
  Balance: {{ acct.Balance }}
</div>

Here is a Demo

JoseM
  • 4,302
  • 2
  • 24
  • 35