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?

3
  • possible duplicate of Accessing JSON object keys having spaces Commented May 1, 2014 at 15:37
  • maybe you can add more context? it looks like yourvar['your key'] should be enough Commented May 1, 2014 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! Commented May 1, 2014 at 16:14

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

thanks JoseM. That was maybe the only permutation I hadn't thought about. Very strange.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.