ionic-team / ionic-team/ionic-docs

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

Aperta
#2,734 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
content
Lingua principale
MDX
Stelle
621
Fork
3.2k
Merge medio
1g 2h
PR unite (30g)
86

Descrizione

### 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++;
});
}
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.