如果我的密钥以“$”开头,则ng-repeat不能正常工作。我认为angularjs可能会将此视为$ index的特殊指令。有没有办法让它发挥作用?
<div ng-app='app'>
<h1 ng-repeat='(key,val) in {"SimpleKey":"This works fine"}'>{{key}}:{{val}}</h1>
<h1 ng-repeat='(key,val) in {"Key/$/FOO":"This works fine"}'>{{key}}:{{val}}</h1>
<h1 ng-repeat='(key,val) in {"$/FOO":"This does NOT work fine!"}'>{{key}}:{{val}}</h1>
</div>
您可以尝试:Code Pen
答案 0 :(得分:0)
在$之前放置空格它适合你
答案 1 :(得分:0)
只需在密钥前添加一个空格:
<h1 ng-repeat='(key,val) in {" $/FOO":"This work fine!"}'>{{key}}:{{val}}</h1>