How to access data contained in two Collections at the angular?

Asked

Viewed 28 times

0

I have a JSON that has the data of the person and another Collection with "countsJogadors", how do I make my listing also show what is in "contasjogadors"?

My JSON:

{
    "nome": "Ramos Janones",
    "email": "[email protected]",
    "cpf": "03472925698",
    "celular": "34996320391",
    "telefone": "",
    "cep": "38300070",
    "endereco": "DEZESSEIS",
    "cidade": "Ituiutaba",
    "estado": "Minas Gerais",
    "bairro": "",
    "complemento": "",
    "usuario": "ramos",
    "senha": "teste123",
    "idppoker": "",
    "nickppocker": "ramosinfo",
    "numero": "",
    "_id": "5bf18c512af2e61ab879d2f7",
    "createdAt": "2018-11-18T15:59:13.735Z",
    "updatedAt": "2018-11-26T15:41:00.806Z",
    "__v": 0,
    "id": "5bf18c512af2e61ab879d2f7",
    "foto": {
        "_id": "5bfc140dbe257a17900442a1",
        "name": "8.jpg",
        "sha256": "Mt3053NTSRC81wiHOEMubEUagRAPlHOR-MtPvf2yKgQ",
        "hash": "36cdc8491d7b4fa1817bed8126b3143e",
        "ext": ".jpg",
        "mime": "image/jpeg",
        "size": "58.46",
        "url": "/uploads/36cdc8491d7b4fa1817bed8126b3143e.jpg",
        "provider": "local",
        "related": [
            "5bf18c512af2e61ab879d2f7"
        ],
        "createdAt": "2018-11-26T15:41:01.003Z",
        "updatedAt": "2018-11-26T15:41:04.113Z",
        "__v": 0,
        "id": "5bfc140dbe257a17900442a1"
    },
    "contasJogadors": [
        {
            "agencia": "3251",
            "digito_agencia": "4",
            "numero_conta": "10000",
            "digito_conta": "4",
            "_id": "5bfeedf374e1f00d88e22f83",
            "createdAt": "2018-11-28T19:35:15.130Z",
            "updatedAt": "2018-11-28T19:37:09.715Z",
            "__v": 0,
            "id": "5bfeedf374e1f00d88e22f83",
            "jogador": "5bf18c512af2e61ab879d2f7",
            "tipocontas": null,
            "bancos": null
        }
    ]
}

My List with *ngFor:

<ol *ngFor="let conta of contas; let i = index">
  <li><strong>Dados Bancários: </strong> Tipo da conta: {{conta.tipo_da_conta}} - Banco:
    {{conta.nome_banco}} <br/>Agencia: {{conta.agencia}}-{{conta.digito_agencia}} - Conta:
    {{conta.numero_conta}}-{{conta.digito_conta}}
  </li>
</ol>
  • 1

    Where is the tipo_da_conta in your JSON? Theoretically it would be conta.contasjogadors.jogador, for example.

  • I tried this way and it won’t come back.

  • Where is the tipo_da_conta in your JSON?

  • 1

    @Ramos You just need to add another *nfFor to the field you want, in case [...] *ngFor="let contasJogadors of contas.contasJogadors; let i = index"[...]

  • It worked. Thanks a lot @edsonalves

  • @edsonalves if possible put the answer to mark as solved. Thank you.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.