How to use Swiperjs CDN in Angular?

Discussão em 'Angular' iniciado por felixo, Janeiro 15, 2025.

  1. felixo

    felixo Guest

    I understand there is a module, but I would like to use Swiper js in my angular app through its CDN.

    I have included the scripts in head of my index.html.

    Then in the component where I want to use it, I have delared it as such:

    import { Component, OnInit } from '@angular/core';
    import { MenuService } from '../_services/menu.service';
    import { ContentfulService } from '../_services/contentful.service';
    import { Entry } from 'contentful';
    declare let Swiper: any;

    /* and initialised in the constructor*/

    constructor(
    public menu: MenuService,
    private contentfulService: ContentfulService
    ) {
    new Swiper('.swiper-container', {
    // Optional parameters
    direction: 'vertical',
    loop: true,
    });
    }


    I am not getting any errors, but it simply will not work. The arrows for instance are also loaded but there is no event bound to them. Any help is much appreciated.

    Continue reading...

Compartilhe esta Página