Using Swiper inside angularjs?

I’m trying to use inside my ionic project. I created this directive :

.directive('waitForSlider1', function ($timeout){
    return {
        link: function($scope, $element, $attrs) {
            if ($scope.$last === true) {
                $timeout(function() {
                    new Swiper('.swiper-container1',{
                      //Your options here:
                      loop: true,
                      slidesPerView: 1,
                      pagination: '.pagination1'

But now, I can’t get ng-click to work. Any ideas why ?

1 Like

Just curious, why that slider? Ionic already comes with a Slider built in

I tried but it did not work for my needs. I needed to be able to display 4 slides a the same time.

If only I could use ionic slider …

Ahh, fair enough then. Do you mind posting a codepen? I’ll do some digging in the dev tools and see whats the issue is.

You can always put a feature request in to extend the slide box’s feasters to have multiple slides at one

I have tried doing this as well. The issue doesnt have to do with ionic, it has to do with the guts of how idangerous swiper works. It basically takes the html container you designate for the swiper and removes it and creates all new dom elements for the finished swiper. Since this html arrives after the templates for the page were bound to scope, it ignores any angular directives you add. I did get this working at one point for a project I had so let me look at it my old code and see what I can post. I think i basically did some command to point angular at that chunk of html and forced it to add it to the current scope.

i do it :slight_smile: please check repo
this work in dynamic view in routing and have a tricky solution for mix ng-click and onSlideClick
download repo and extract it, copy to xampp htdoc(or wamp or any web server) and go to http://localhost/ to see demo

It is an old thread but for someone looking for the same feature

I have created a directive that helps wrap the swiper library

<ks-swiper-container initial-slide="3" loop="false" show-nav-buttons="false" slides-per-view="4" space-between="5" pagination-clickable="false">
    <ks-swiper-slide class="swiper-slide" ng-repeat="s in [1,2,3,4,5,6,7,8,9,10,11,12,13,14]">
        <img ng-src="{{s}}.jpg">
1 Like

Thank ypu @ksachdeva !! I’m using it and I starred it in GitHub