Manipulate Firebase data in controller with angle 1

0

I'm working with Angular 1, angularfire and Firebase. I made the following call that returns the following data to me:

var _refLista = firebase.database().ref()
$scope.lista = $firebaseObject(_refLista.child('listas').child(idLista))
console.log($scope.lista);

In the console the data appears structured as follows:

{
    nome: "nome da lista",
    usuarios: [0:"OkJiuyhTfrdgF", 1:"kjIugYHTkiuh"]
}

In the view I can print everything, eg:

{{ lista.nome }}
{{ lista.usuarios }}

But when I try to access $ scope.list.users in the controller the result is always undefined.

Can anyone help?

    
asked by anonymous 15.02.2017 / 01:12

1 answer

1

You loaded an object from the "$ firebaseObjec" it returns a JavaScript object that contains the Firebase data with some additional and specific AngularFire fields, this object may not be fully available because of asynchronous loading, use the $ loaded () function to load the example object:

   $scope.lista = $firebaseObject(_refLista.child('listas').child(idLista))
   $scope.lista.$loaded().then(function (res) {           
       //AQUI VOCÊ PODE LER AS PROPRIEDADES
       console.log("Minha lista",lista.usuarios)             
   })  
    
15.02.2017 / 18:33