Here's the scenario: I have a simple question regarding an Angular component. Inside this component, there is a function structured like this:
somethingCollection: TypeSomething[]
...
public deleteSomething(something: TypeSomething): void {
// something variable is within this scope
this.someAPI.deleteSomething(something.id).subscribe( (res) => {
// need to update this.somethingCollection here
// but unable to access 'something' in outer scope
}
}
It's clear that for updating this.somethingCollection, we require 'something.id'. However, once inside the subscribe method, I lose access to it.
Is there anyone who can guide me on how to retain access to function scoped variables within the subscribe method?