I\'m new to observables in angular. I have a problem wanting to return a value inside a subscribe method. I have
the following method (getFirebaseData(idForm:string):o
You can't directly return totalQuestions like that, you need to use a subject to achieve that.
getTotalQuestions(idForm:string): Observable {
let totalQuestions:number;
var subject = new Subject();
this.getFirebaseData(idForm+"/Metadatos")
.subscribe(items => {
items.map(item => {
totalQuestions=item.Total;
console.log(totalQuestions);
subject.next(totalQuestions);
});
}
);
return subject.asObservable();
}
Usage: getTotalQuestion(idForm).subscribe((r)=>console.log(r))