I am currently developing an application with Angular and Typescript where I need to update the value of a variable inside a function. To retrieve the data required, I'm utilizing a service. Below is the code snippet for reference:
let isDataAvailable: boolean = false;
onChangeValue(list: List) {
this.someService.getData(list).subscribe(
item => {
if(item.value === 1) {
isDataAvailable = true;
}
});
console.log(isDataAvailable); // The value still remains false at this point
}