Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to iterate over firebase data object to list

firebase data

logging data

 this.fb.getShoppingItems().then(result =>{
   this.exercises=result;
   console.log("this exercise : ");
   console.log(this.exercises);
 })

I should list firebase data but getting error like below

Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

first pic is my firebase data structure and second one is console.log result.

in html , I should iterate over exercises came from firebase data(interval_time, name, rest_time, time)

I think I should iterate over . for each date node like 20170710/20170711 ... How can I do that?

like image 723
Pd.Jung Avatar asked Dec 13 '22 22:12

Pd.Jung


1 Answers

For JavaScript I would do

firebase.database().ref("profile/user_id").on('value', function(snap){

   snap.forEach(function(childNodes){

      //This loop iterates over children of user_id
      //childNodes.key is key of the children of userid such as (20170710)
      //childNodes.val().name;
      //childNodes.val().time;
      //childNodes.val().rest_time;
      //childNodes.val().interval_time;


  });
});
like image 156
Ziya ERKOC Avatar answered Dec 21 '22 11:12

Ziya ERKOC