Call function from another page / controller

I searched here on the forum for some solution but I found some complicated.
I am learning to use the angular / ionic.

I have a function that updates a list through an event, and I would like to call another function on another page to update that counts the total items in the list.

I will be grateful to anyone who can help me ^^


    setTimeout(() => {
     this.sTxt = null;
     this.sTipo = 0;
      this.start = 0;
    }, 500);


       let dados = { requisisao: 'hTotal' };
       this.provider.Api(dados, 'api.php').subscribe(async data => {
           this.hTotal = data['total'];
         else { this.hTotal = 0; }

i think you should use service for that. make one service and create your function within it then use that service in both page.

1 Like

In addition to @hirenkorat3ā€™s excellent advice above, I am very suspicious of setTimeout, especially with magic numbers. What is that doing there?

Iā€™m using ion-refresher

Then I would totally reverse the way your code is organized. Lifecycle events like ngOnInit are designed to be called from the framework, not from app code. Instead, have ngOnInit call doRefresh, which will allow doRefresh to return a future indicating when it has done its job, and you can use that to determine when to call target.complete, not a random arbitrary delay.