J'essaie de créer une page de notification qui s'ouvre à partir des onglets. Après avoir ouvert la page, elle doit se rafraîchir pour que les nouvelles notifications soient visibles et que ces notifications soient lues et que le badge sur les onglets soit 0.Les onglets ioniques n'entrent pas dans le constructeur de la page plusieurs fois
La première fois que vous ouvrez la page de notification, il entre dans le constructeur mais il ne rentre pas.
Ça fonctionnait bien avant mais ça ne marche plus, je ne sais pas pourquoi.
Page de notification;
constructor(public events: Events, public navCtrl: NavController, public
navParams: NavParams, private notificationservice: NotificationService,
private loadingCtrl: LoadingController) {
this.notificationservice.getNotifications(AuthService.currentUser.UserId).then(
data => {
this.notifications = data;
this.notificationservice.unreadNotificationCount().then(data => {
if(data != 0)
{
this.notificationservice.readNotification().then(data => {
this.updateBadge();
this.navCtrl.setRoot(this.navCtrl.getActive().component);
});
}
});
});
}
public updateBadge()
{
this.notificationservice.unreadNotificationCount().then(data => {
console.log(data);
this.events.publish('cart:updated', data);
});
}
Onglets Page;
constructor(public navCtrl: NavController, public navParams: NavParams,
private notificationservice: NotificationService, public events: Events) {
this.updateBadge();
this.events.subscribe('cart:updated', (count) => {
this.badge = count;
});
}
public updateBadge()
{
this.notificationservice.unreadNotificationCount().then(data => {
console.log(data);
this.events.publish('cart:updated', data);
});
}
Affichage des onglets;
[. S'il vous plaît ne pas poster votre code comme une image] (// meta.stackoverflow.com/q/285551) –
@suraj Je l'édite. – esdoodle