html - 使用angular js在html中显示json嵌套对象的数据

标签 html angularjs

angularjs 的新手。尝试像这样显示来自 json 嵌套对象的数据

enter image description here

我的html代码是

<a rel="extranal" data-val="<%rcds%>" ng-repeat="rcds in rcd" class="international" id="<%rcds.id%>">
<span><img ng-src="<% rcds.routes.subroutes %>"/> <% rcds.subroutes[0].xyz%></span>
<div class="departure-time"><% rcds.subroutes[0].abc %></div>
</a>

想根据json中的legtype条件在ng-repeat中显示数据子路由。如何实现。

最佳答案

如果你想将你的对象显示为 JSON,你唯一需要做的就是编写 {{rcds | json}}

否则,如果你想导航你的嵌套对象,你应该这样做:

<div ng-repeat="rcds in red">
  <div ng-repeat="route in rcds.routes">

    <!-- route element --->

      <div ng-repeat="depart in route.depart">

        <!-- depart element --->

        <div ng-repeat="subroute in route.subroutes">

          <!-- subroute element -->

        </div>

     </div>

  </div>
</div>

关于html - 使用angular js在html中显示json嵌套对象的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39074314/

相关文章:

javascript - 在 AngularJS 中设置应用程序范围的 HTTP header

html - 优雅的 CSS 间距定位

html - CSS:只修改类中的一个元素

javascript - 为什么我的函数不显示数据?

javascript - ng-click 在 firefox 中不起作用

javascript - 当 AngularJS jqlite 不存在损坏的 url 时,将损坏的 img url 替换为默认值

javascript - 单击时动态按钮不起作用 - Javascript

html - Bootstrap 3 : input-group mixed with non input-groups different sizes

javascript - 如何在没有抗锯齿的情况下将缩放文本作为图像

javascript - 将 JSON 对象传递给 ng-init