Polymer - Firebase: iterate over Firebase data

0

Good morning, I have this data in firebase:

Under each year_mes the key is the ID of each user that has been registered in that month and what I want to do is in a "parent" component to get a list of all users and then in the child component to know if that user is registered in that year_month, however I can not do it :( I have this in the parent component:

<template is="dom-repeat" items="{{usuarios}}" as="usuario">
<admin-consulta-pagos-item usuario="{{usuario}}" yearmes="{{yearmes}}" id="consultaspagos"></admin-consulta-pagos-item> </template>

and in the child component I have the property: paid that is Boolean and I only want it to be blended at check: (

consultar: function () {
            that = this;
            var usuariocreado = this.fbref('/yearmes/' + this.yearmes + '/' + this.usuario.$key);
            usuariocreado.once('value')
            .then(function (snapshot) {
                var a = snapshot.exists();
                console.log('existe en BD: ' + a);
                if (a) {
                    console.log('El usuario PAGO: ' + a)
                    that.pagado = true;
                } else {
                    that.pagado = false;
                }
            });
        },

The strange thing is that the console.log that I have there works perfectly for me and tells me if the registration is or not, but the paid property is not affected correctly :( only the last one, maybe I'm not thinking it right or something I'm not considering can anyone suggest something to me to do this?

Here is the example of the app screen where the three are in that month and only mark the last: (

Thank you very much.

    
asked by Marcos Galaviz 07.12.2016 в 16:20
source

1 answer

0

You have the line:

that = this;

Without the word "var". In this way, a global variable "that" is generated and its value is always crushed with the last assignment. That's why only the value is activated in the last position and not in all the others.

I hope I helped you

    
answered by 14.12.2016 / 20:20
source