Obtaining a specific property of a JSON object

1

I have the following JSON:

 {
  "2016": {
    "mes": {
      "2": {
        "dia": {
          "5": {
            "-KcENENmSJcZp56clzz5": {
              "descricao": "teste",
              "valor": "99"
            }
          }
        }
      }
    }
  },
  "2017": {
    "mes": {
      "2": {
        "dia": {
          "5": {
            "-KcELskoSWWttptIgb0L": {
              "descricao": "xx",
              "valor": "55"
            }
          }
        }
      }
    }
  },
  "$id": "ano",
  "$priority": null
}

This is a return from firebase, I would like for example to get the value 2016 .

Use the angular to populate a list like this:

<li ng-repeat="gasto in gastos"> 

</li>

If within my tag li I use {{gasto.$id}} it prints "ano" and I'm not able to get the value 2016 for example.

    
asked by anonymous 05.02.2017 / 20:58

1 answer

3

You'll get it like this:

{{ gasto['2016'] }}

Result:

"mes": {
  "2": {
    "dia": {
      "5": {
        "-KcENENmSJcZp56clzz5": {
          "descricao": "teste",
          "valor": "99"
        }
      }
    }
  }
}
    
05.02.2017 / 22:36