ionic-team / ionic-team/ionic-docs

content: The IonSlides Angular migration guide should have "Notes" about the breaking change on Event handling

Ouverte
#2,734 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
content
Langage dominant
MDX
Étoiles
621
Forks
3.2k
Merge moyen
1 j 2 h
PR mergées (30 j)
86

Description

### URL

https://ionicframework.com/docs/angular/slides#events

### Issue Description

When following the migration guide to switch using Swiper instead of IonSlides, I found one breaking change.
That is the triggered event is no longer part of NgZone.
This is also mentioned in the Swiper document.
https://swiperjs.com/angular#swiper-component-events

> Note that Swiper Angular component all events emits outside of NgZone for better perfomance. Dont forget to use `ngzone.run` or ChangeDetector if you need to change view (e.g slides) in event handlers (e.g `slideChange`).

I think this should also be mentioned in the Ionic docs.

Below is a small sample:
In HTML, I put a testVariable both inside and outside of Swiper.
```
{{testVariable}}

Slide1, {{testVariable}}
Slide2 {{testVariable}}
Slide3 {{testVariable}}

```
In component code, if I don't surround the code with ngZone.run, only the testVariable inside Swiper is updating, the one outside of Swiper never changes. IonSlides doesn't have such behavior change.
```
onSlideChange() {
this.ngZone.run(() => {
this.testVariable++;
});
}
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.