如何在角js中读取这个json [英] How to read this json in angular js
问题描述
"{"success":1,"pager":{"page":1,"per_page":50,"total":8},"results":[{"id":"28919295","sport_id":"4","time":"1537781400","time_status":"1","league":{"id":"9991615","name":"County Championship Div 1 Matches"},"home":{"id":"25506","name":"Hampshire"},"away":{"id":"36395","name":"Lancashire"},"our_event_id":"703252"},{"id":"28919296","sport_id":"4","time":"1537781400","time_status":"1","league":{"id":"9991615","name":"County Championship Div 1 Matches"},"home":{"id":"36396","name":"Nottinghamshire"},"away":{"id":"35814","name":"Somerset"},"our_event_id":"703312"},{"id":"28919302","sport_id":"4","time":"1537781400","time_status":"1","league":{"id":"9991615","name":"County Championship Div 1 Matches"},"home":{"id":"37313","name":"Surrey"},"away":{"id":"34775","name":"Essex"},"our_event_id":"703203"},{"id":"28919306","sport_id":"4","time":"1537781400","time_status":"1","league":{"id":"9991615","name":"County Championship Div 1 Matches"},"home":{"id":"36397","name":"Worcestershire"},"away":{"id":"36394","name":"Yorkshire"},"our_event_id":"703313"},{"id":"28919313","sport_id":"4","time":"1537781400","time_status":"1","league":{"id":"9991613","name":"County Championship Div 2 Matches"},"home":{"id":"37318","name":"Glamorgan"},"away":{"id":"37317","name":"Leicestershire"},"our_event_id":"703276"},{"id":"28919315","sport_id":"4","time":"1537781400","time_status":"1","league":{"id":"9991613","name":"County Championship Div 2 Matches"},"home":{"id":"37319","name":"Durham"},"away":{"id":"36401","name":"Middlesex"},"our_event_id":"703239"},{"id":"28919319","sport_id":"4","time":"1537781400","time_status":"1","league":{"id":"9991613","name":"County Championship Div 2 Matches"},"home":{"id":"37316","name":"Derbyshire"},"away":{"id":"36398","name":"Gloucestershire"},"our_event_id":"703238"},{"id":"28919322","sport_id":"4","time":"1537781400","time_status":"1","league":{"id":"9991613","name":"County Championship Div 2 Matches"},"home":{"id":"36399","name":"Warwickshire"},"away":{"id":"26182","name":"Kent"},"our_event_id":"703240"}]}"
我的尝试:
< tr ng-repeat =r in result.results track by $ index >
< td>
{{r.home.name}}
< span class =glyphicon glyphicon-star-空style =颜色:#ff9008;>< / span>
< a href =event.html> {{r.results [0] .home.name } {V} {{r.results [0] .away.name}}< / a>
< div style =text-align:right>< small> 15 / 09/2018 05:30< / small>< / div>
< / td>
无法获得home.name和away.name如何实现这一目标?
What I have tried:
<tr ng-repeat="r in result.results track by $index">
<td>
{{r.home.name}}
<span class="glyphicon glyphicon-star-empty" style="color: #ff9008;"></span>
<a href="event.html">{{r.results[0].home.name}} Vs {{r.results[0].away.name}}</a>
<div style="text-align: right"><small>15/09/2018 05:30</small></div>
</td>
unable to get home.name and away.name how to achieve this?
推荐答案
index>
< td>
{{r.home.name}}
< span class =glyphicon glyphicon-star-emptystyle =color:#ff9008; >< / span>
< a href =event.html> {{r.results [0] .home.name}} Vs {{r.results [0 ] .away.name}}< / a>
< div style =text-align:right>< small> 15/09/2018 05:30< / small> < / div>
< / td>
无法获得home.name和离开.name如何实现这个目标?
index">
<td>
{{r.home.name}}
<span class="glyphicon glyphicon-star-empty" style="color: #ff9008;"></span>
<a href="event.html">{{r.results[0].home.name}} Vs {{r.results[0].away.name}}</a>
<div style="text-align: right"><small>15/09/2018 05:30</small></div>
</td>
unable to get home.name and away.name how to achieve this?
请参阅此 Code Project 1261440的代码笔 [ ^ ]
它工作正常。
总是好的ide独立运行代码,以便人们可以轻松地帮助您。创建这种独立环境也可以帮助您识别错误。
see this Code pen for Code Project 1261440[^]
it is working correctly.
It is always good to provide independent running code so that people can easily help you. Creating this kind of independent environment also help you to identify your mistakes.
这篇关于如何在角js中读取这个json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!