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
To solve this I would create a property totalQuestions$ an observable
In the TS file
totalQuestions$ = this.getFirebaseData(idForm + "/Metadatos").pipe(
map(items => items.reduce((prev, {Total}) => prev + Total), 0)))
)
And Now in your template you can use async pipe
{{ totalQuestions$ | async }}
If you would like to use the variable in your TS file, then you can use combination operators like forkJoin or combineLatest to access this value
newVariable$ = combineLatest([totalQuestions$, ...]).pipe(
map(([totalQuestions, ... ]) => {
// Perform an operation here and return a value
})
)