bug: ion-slides swiper instance does not get re-initialized with angular ivy
See original GitHub issueBug Report
Ionic version:
[x] 5.0.0-rc.2
Current behavior:
With angular ivy enabled (9.0.0-rc.12) ion-slides
(specifically the swiper instance) does not get re-initialized after destroyed once and is therefore unusable afterwards.
Expected behavior:
Swiper instance gets re-initialized, ion-slides
keep working.
Steps to reproduce:
- clone sample app
- npm i
- ionic serve
- open console
- click on “Go to slides page”
- click “Go to next slide” (working!)
- click back button
- click on “Go to slides page” again
- “Go to next slide”, “Go to previous slide” is broken
- check console, unfold logged
Swiper
object ->destroyed: true
Related code:
A sample application via GitHub
Other information: Removing the following line fixes the problem, but I don’t think that its a solution to the problem.
Related: ngx-swiper-wrapper#226 As ionic is shipping the swiper directly embedded into the framework maybe it needs to be compiled with ngcc once.
Ionic info:
Ionic:
Ionic CLI : 5.4.15 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 5.0.0-rc.2
@angular-devkit/build-angular : 0.900.0-rc.12
@angular-devkit/schematics : 9.0.0-rc.12
@angular/cli : 9.0.0-rc.12
@ionic/angular-toolkit : 2.1.2
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : ios 5.1.1
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 4 other plugins)
Utility:
cordova-res : not installed
native-run : not installed
System:
ios-deploy : 1.9.2
ios-sim : 8.0.2
NodeJS : v12.4.0 (/usr/local/bin/node)
npm : 6.11.3
OS : macOS Catalina
Xcode : Xcode 11.3.1 Build version 11C504
Issue Analytics
- State:
- Created 4 years ago
- Reactions:18
- Comments:38 (18 by maintainers)
Top Results From Across the Web
Ionic 5 angular - migrate ion-slides to swiper.js
Error: Type SwiperComponent is part of the declarations of 2 modules. The issue above basically occurs when a component is declared in 2 ......
Read more >Set Up Swiper.js for Angular Slides [Example]
Read this guide to learn how to get Swiper.js for Angular set up in your Ionic Framework application for a modern touch slider...
Read more >swiper js get current slide
Current behavior: With angular ivy enabled (9.0.0-rc.12) ion-slides (specifically the swiper instance) does not get re-initialized after destroyed once and ...
Read more >How to use Swiper with Ionic (instead of ion-slides) - YouTube
In this video we will implement the Swiper component without ion-slides, since it will be deprecated with Framework v6!
Read more >Building a slideshow with Ionic Slides API
Out of all of these my favourite has to the Ion Slides component ... into the underlying Swiper API that the Ionic Slides...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is a workaround for this issue. Simply postpone the slider initialization with ngIf and the angular lifecycle.
my-component.html
my-component.ts
Thanks for the issue. This has been resolved via https://github.com/ionic-team/ionic/pull/20899 and will be available in an upcoming release of Ionic Framework.