如何使用angularjs动态加载htmltable中的嵌套数组属性?

How to dynamically load the nested array attributes in html table using angularjs?

这是我试过的代码,但只有 cardno 和 cardtype 的值,为什么我无法访问其余的代码?有什么建议吗?

<tr ng-repeat="data in myData17.layouts">
  <td ng-show="$index==1">{{data.name}}</td>
  <td ng-show="$index==1">
    <table>
      <tr ng-repeat="card in data.cards">
        <td>{{card.cardNo}}</td>
      </tr>
    </table>
  </td>
  <td ng-show="$index==1">
    <table>
      <tr ng-repeat="card in data.cards">
        <td>{{card.cardType}}</td>
      </tr>
    </table>
  </td>
  <td ng-show="$index==1">
    <table>
      <tr ng-repeat="card in data.cards.ports">
        <td>{{card.portNo}}</td>
      </tr>
    </table>
  </td>
  <td ng-show="$index==1">
    <table>
      <tr ng-repeat="card in data.cards.ports">
        <td>{{card.portName}}</td>
      </tr>
    </table>
  </td>
  <td ng-show="$index==1">
    <table>
      <tr ng-repeat="card in data.cards.ports">
        <td>{{card.portType}}</td>
      </tr>
    </table>
  </td>
  <td ng-show="$index==1">
    <table>
      <tr ng-repeat="card in data.cards.ports">
        <td>{{card.portspeed}}</td>
      </tr>
    </table>
  </td>
  <td ng-show="$index==1">
    <table>
      <tr ng-repeat="card in data.cards.ports">
        <td>{{card["ds-scheduler-node-profile"]}}</td>
      </tr>
    </table>
  </td>
</tr>

这是我的数据。

      {
  "name": "twoCardOneEthportAndOne10G",
  "cards": [{
    "cardNo": "1",
    "cardType": "Ethernet",
    "ports": [{
      "portNo": "1",
      "portName": "LAN1",
      "portType": "ethernetCsmacd",
      "portspeed": "eth-if-speed-1gb",
      "ds-scheduler-node-profile": "default"
    }]
  },
    {
      "cardNo": "10",
      "cardType": "Ethernet",
      "ports": [{
        "portNo": "1",
        "portName": "10GE",
        "portType": "ethernetCsmacd",
        "portspeed": "eth-if-speed-10gb",
        "ds-scheduler-node-profile": "default"
      }]
    }]
}

data.cards.ports不是东西。

ports属性是单数cardcards是一个数组。

它必须像这样访问:

data.cards[0].ports

那么,这在您的代码中是如何构建的?您可能需要这样的东西(这不是您确切实施的解决方案,只是一个视觉指南,可帮助您以您需要的方式访问数据)

<div ng-repeat=“data in myData17.layouts”>
    {{ data.name }}
    <div ng-repeat=“card in data.cards”>
        {{ card.cardNo }}
        <div ng-repeat=“port in card.ports”>
            {{ port.portNo }}
        </div>
    </div>
</div>

希望这能让您更好地理解并祝您好运