I have a problem with my Angular2 Type Script code. I'm trying to access Questions from a Firebase Database, which I am doing by subscribing to a FirebaseListObserver:
this.af.list('/questions').subscribe( val => {
this.questions = val
console.log(this.questions) // works
})
console.log(this.questions) // displays undefined
I dont know how to wait for the subscription to get a value, though, before running a function which depends on this.questions
.
I tried to use async/await, but also didn't wait for the subscription to get a value.
I also tried to subscribe inside a promise, but also returned an empty array.