ionic-team / ionic-team/ionic-docs

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

Open
#2,734 0 comments 0 reactions 0 assignees View on GitHub
content
Dominant language
MDX
Stars
621
Forks
3.2k
Avg merge
1d 2h
Merged PRs (30d)
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++;
});
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.