Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 'swiper-slide' is not a known element after migrating from ion-slides

I updated my Angular Ionic 5 application and trying to migrate from ion-slides to Slides. I am following the official docs.

  • I installed swiper npm install swiper@6
  • Did import in the scss file @import '~swiper/swiper';
  • Did import the SwiperModule in app.module.ts and my page.module.ts
import { SwiperModule } from 'swiper/angular';
@NgModule({
  imports: [SwiperModule],
})
export class AppModule {}

The HTML page is able to recognize swiper after I imported the SwiperModule in my page.module.ts but it's not able to recognize swiper-slide and showing error 'swiper-slide' is not a known element

<swiper>
  <swiper-slide>Slide 1</swiper-slide>
  <swiper-slide>Slide 3</swiper-slide>
  <swiper-slide>Slide 3</swiper-slide>
</swiper>
like image 253
Tapas Mukherjee Avatar asked Sep 14 '21 13:09

Tapas Mukherjee


People also ask

How do you use slides in ionic?

By default, Ionic Slides components use the built-in slide animation effects. But, you can also use the custom animations for your Slides components. It can be done by using the options property, which looks like below syntax. You can find the different slider parameter options from here.

How do I create an ionic image slider?

You could use ion-slide-box , then you need to set slide-interval to 30000 to change image in 30 seconds, its default to 4 seconds. Show activity on this post.

When Swiper slider does not fire slidechange event?

Swiper Slider does not fire slideChange event when active slide changed automatically from last slide to first slide. Swiper Slider does not fire slideChange event when active slide changed by user to last slide In reverse direction.

What events does Swiper angular component support?

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`). Swiper component supports all Swiper events, including additional swiper event that returns swiper instance as soon as possible.

What are the slots available for content distribution in Swiper component?

Swiper Angular component uses "slots" for content distribution. There are 4 slots available container-start - element will be added to the beginning of swiper-container container-end (default) - element will be added to the end of swiper-container


1 Answers

After adding to AppModule, Please add SwiperModule to Page Level Module also where component is registered.

like image 107
Shivinder Singh Avatar answered Oct 18 '22 01:10

Shivinder Singh