In this function, I am trying to access the value of the 'value' array outside the function in the same class. This function is being called in a setter method where the ID is set like so: setId(id:string){ this.onChange(id)}
class ModalShowComponent implements OnInit {
onChange(id) {
this.xyzService.getCodes(id).subscribe(
list => {
var value = [];
list.forEach((object) => {
value.push(object.payload.val());
});
// some code
return value;
});
}
}