0

I have 2 functions. I am fetching data from one function how can i call the data value from other function

Here is code example

export class IntroPage {

  fun1() {

  this.messageService.getGroupMessages(this.group_id).subscribe( (data:any) => {
  console.log(data);
  this.groupname = data.groupname; // As here need to show this.groupname in second function
  });

  }

  fun2() {

   console.log(this.groupname); // Need to show value here 

  }
}

I know i can pass value by function like this.fun2(this.groupname); But i dont want to do like this. There is any way to show without passing it through the function or set it globally in file ?

rameez khan
  • 73
  • 1
  • 23
  • 68

0 Answers0