Hello there. I am developing a virtual market application.
I am running an event in the tab menu when I delete the cart. But this event is working twice. The first time I open the program, it only works once, but when I repeat the same operation a second time, the event works twice.
How can I solve this problem?
I Share Codes.
Cart Codes :
sepetiSil(){
let loader = this.loader.create({
content : "Lütfen bekleyiniz.."
});
let header = new Headers();
header.append("Content-Type","application/json");
header.append("Accept","application/json");
var base_url = "xxxxxxxxx/xxx";
var veri = JSON.stringify({
BELGEID : this.globalBelgeID
});
loader.present();
this.http.post(base_url, veri, header).map(res=>res.text()).subscribe(data=>{
this.sepetArray.pop();
this.MIKTARMODEL.pop();
this.URUNTUTARMODEL.pop();
this.TOPLAMTUTAR = 0;
this.events.publish('sepet:sayacsifirla');
var mesaj = "Sepet başarıyla temizlendi.";
loader.dismissAll();
this.mesajOlustur(mesaj);
},(error)=>{ loader.dismissAll(); this.sepetiSil(); });
}
Tabs Codes:
this.events.subscribe('sepet:sayacsifirla',()=>{
this.SEPETSAYISI = 0;
this.dizi.pop();
this.SEPETURUNLER.pop();
console.log(this.dizi);
console.log("SAYAÇ SIFIRLANDI VE YÖNLENDİRİLME YAPILDI");
this.app.getRootNav().setRoot(TabsPage);
});
As you can see, the event works twice