Ionic Swipe Cards - 'CardCtrl' not logging swipe direction

Hi there,

I have been working on creating a UI for indicating a user’s preferences using local collide.js and ionic.tdcards.js. I wish to populate an array in $scope with the items the user has indicated a preference for. However, I am having difficulty. The problem is that the swipe direction does not seem to be registering at all when I test in the browser. There is no log to the console for any swipe and it seems as if ‘CardCtrl’ is redundant. I have tried replacing local collide.js and ionic.tdcards.js files with the hosted versions but this has not helped.

I could really do with some advice:

.controller('CardCtrl', function($scope, TDCardDelegate) {
    //var userInterests = [];
    //$scope.interests = userInterests;

    $scope.cardSwipedLeft = function (index) {
        console.log('LEFT SWIPE');
        //nothing
        $scope.addCard();

    };
    $scope.cardSwipedRight = function (index) {
        console.log('RIGHT SWIPE');
        //add to array

        $scope.addCard();

    };

The template markup:

 <td-cards>
            <td-card ng-repeat="card in cards" on-destroy="cardDestroyed($index)" on-swipe-left="cardSwipedLeft($index)" on-swipe-right="cardSwipedRight($index)" on-partial-swipe="cardPartialSwipe(amt)" class="card-{{$index}}">
                <div class="image" ng-controller="CardCtrl">
                    <div class="no-text">
                        <img class="imgX" src="img/dislike.png"/>
                    </div>
                    <!--<div class="fave yes-text demo-container tap-to-activate" on-swipe-left='animateStar()'></div>-->
                    <img class="swipeImg" ng-src="{{card.image}}">
                    <div class="yes-text">
                        <img class="imgCheck" src="img/like.png"/>
                    </div>
                </div>
            </td-card>
        </td-cards>

The problem appears to be with the functions:

on-swipe-left="cardSwipedLeft($index)"

and

on-swipe-right="cardSwipedRight($index)

which are not triggering the logging of swipe direction to the console.

Instead of on-swipe, use on-transition

1 Like