【发布时间】:2014-07-02 13:53:43
【问题描述】:
我在标签中有带有冒号的 json 数据(请参阅响应数据),我发现很难使用以下代码在 Angular 中访问这些数据:
<li ng-repeat="i in items.autnresponse.responsedata | searchFor:searchString"> <p>{{i.autn:numhits}}</p> </li>
我不断收到这样的错误:
Error: [$parse:syntax] Syntax Error: Token ':' is an unexpected token at column 7 of the expression [i.autn:numhits] starting at [:numhits].
JSON 数据摘录:
"autnresponse": {
"action": {
"$": "QUERY"
},
"response": {
"$": "SUCCESS"
},
"responsedata": {
"autn:numhits": {
"$": "92"
},
"autn:totalhits": {
"$": "92"
},
"autn:totaldbdocs": {
"$": "188"
},
"autn:totaldbsecs": {
"$": "188"
},
有人知道解决这个问题的方法吗?
【问题讨论】:
-
您尝试使用哪种语言访问它? JavaScript?珀尔? Python?还有什么?
-
抱歉,尝试使用 angularjs 访问它
-
是无法从 JSON 解析为 JS 结构,还是您编写的一行代码无法访问生成的 JS 结构中的某些内容?如果是后者,请提供代码行。
-
它适用于标签中没有冒号的标签,但是当我尝试像 {{i.autn:numhits}} 这样的东西时,我得到了错误......它不喜欢冒号在json标签中
-
跨度>{{i.autn:numhits}}
标签: javascript json angularjs colon