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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top