IONIC – ANGULAR Why when click back button I have same multiple request?

Published

I have the back button on my pages.
When I stay on PAGE 1 and go to PAGE 2 I have only one request. And when I click the back button from PAGE 2 to PAGE 1 i receive a two same request. If I go to PAGE 2 again and go back I receive three same request.

Why ?

i have this on PAGE 1

 ionViewWillEnter() {

this.route.paramMap.subscribe(paramMap => {
  if (!paramMap.has('id_store')) {
    this.location.back();
    return;
  }
this.isLoading = true;

this.atv_id = paramMap.get('id_store');


    this.loadingCtrl
    .create({ keyboardClose: true, message: 'Carico categorie...' })
    .then(loadingEl => {
      loadingEl.present();

      this.subcriber = this.ristoserv.postRistoCategories(this.atv_id).subscribe( (response: any ) => {

        // check zona selezionata
        this.storage.getObject('zoneData').then((data: any) => {
        });

        this.categories = response;
        this.IdType = paramMap.get('id_type');

        this.isLoading = false;
        loadingEl.dismiss();

      }, errRes => {

        loadingEl.dismiss();
        const code = errRes.error.error.message;
        console.log('error', code);
        this.isLoading = true;

      });

    });

});

};

Source: Angular Questions

Published
Categorized as angular, back-button, ionic-framework Tagged , ,

Answers

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq