Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello im new to ionic 2 and also for anguar 2.Here is my code for login using firebase.I used foreach method in firebase documentation.in here
The thing is how i can return the key and child data to global variables?
if i use console.log it will show the correct value but i can't find a way to get the values out and pass it to next page.
Any suggestions??

Thank You

What I have tried:

Login(){
  
  let x = this.tyindexno;
  let y =this.typassword;
var query = this.userlistRef.orderByKey();
query.once("value",function(snapshot) {
    snapshot.forEach(function(childSnapshot) {
      var key = childSnapshot.key;
      if(key==x){
      // Cancel enumeration
      console.log(key);
      var childData = childSnapshot.val();
      
      if(childData.password==y){
     console.log(childData.password);
      }
      return true;
    }   
  });
})
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900