ionic-team / ionic-team/ionic-docs

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

Offen
#2,734 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
content
Vorherrschende Sprache
MDX
Sterne
621
Forks
3.2k
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
86

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.