Extract certain data from the array of a Json

0

I've got a Json from an API that returns this result:

[
  {
    "marca_id": 4,
    "modelo_id": 2708,
    "versao_id": 65344,
    "cor": "Azul",
    "opcionais": [
      {
        "opcional_id": 6,
        "opcional_nome": "Airbags"
      },
      {
        "opcional_id": 10,
        "opcional_nome": "Freios ABS"
      },
      {
        "opcional_id": 18,
        "opcional_nome": "Ar Condicionado"
      },
      {
        "opcional_id": 22,
        "opcional_nome": "Direção Hidráulica"
      },
      {
        "opcional_id": 19,
        "opcional_nome": "Bancos de Couro"
      }
    ],
    "valor": "40000,00",
    "kilometragem": 97437,
    "imagens": [
      "imagem"
    ],
    "thumbs": [
      "miniatura.jpg"
    ],
    "url_ficha_registro": "0001",
    "loja": "4555"
  }
]

How do I access to print in an ng-repeat all items in the "optional" field? For if I print type {{x.optional}} or {{x.optional [3]}} it returns the array, of course. It may seem like a silly question but am I really pounding it off with having one ng-repeat inside another?

    
asked by anonymous 14.07.2015 / 23:15

2 answers

1

Solved. If anyone needs this below:

<div ng-repeat="dado in x.opcionais">
  {{ dado.opcional_nome }} 
</div>
    
15.07.2015 / 14:20
0

This way:

<tr>
   <td ng-repeat="x.opcionais as dado">
     {{dado.opcional_id}}
     {{dado.opcional_nome}}
   </td>
</tr>
    
14.07.2015 / 23:24