Ionic 3 Firebase I have the Key - How do I access the data?

1

Firstly, I must clarify that I am new to programming, I decided to venture with ionic to start developing. My question is when I want to take firebase information following a route with the respective key:

This is my users table: This is my html: Effectively, I can obtain the key when selecting a user:

I got that key with a console.log.

My question is, having that key of the route, how can I get the values inside it? For example, if from that key I want to obtain the age, the objective, sex, etc?

How would the .ts be?

    
asked by Manuel Augusto Castañeda 10.08.2018 в 00:59
source

1 answer

0

What you can do is the following

To bring all below usuario-list

firebase.database().ref().child("usuario-list").on('value', function(snapshot) {
snapshot.forEach(function(child) {
var datas = child.val();
var edad=child.val().edad;
var objetivo=child.val().objetivo;
var nombre=child.val().nombre;
  });
});

To request a single userID

firebase.database().ref().child("usuario-list").child(userid).on("value", function(snapshot) {

        var edad=snapshot.val().edad;
        var objetivo=snapshot.val().objetivo;
        var nombre=snapshot.val().nombre;
});

if before usuario-list you have another parent you will have to add a child more before .child("usuario-list") to be able to access this node

    
answered by 10.08.2018 / 01:17
source