Having an issue with my Angular2 Type Script code. The goal is to access Questions from a Firebase Database by subscribing to a FirebaseListObserver:
this.af.list('/questions').subscribe( val => {
this.questions = val
console.log(this.questions) // working fine
})
console.log(this.questions) // showing as undefined
Struggling to figure out how to wait for the subscription to receive a value before executing a function that relies on this.questions
.
Experimented with async/await, but it didn't pause for the subscription to return a value.
Tried subscribing inside a promise as well, still ending up with an empty array.