I've done nothing but copy verbatim the example code. i've stripped down everything to just the very basics as you have in the example, but regardless, the directive for swipe-card fails becuase the swipe-cards argument to the directive is never valid...
so this the last argument (swipe-cards) on the compile function for the swipe-card directive line is just never properly set.
Specifically here in the directive won't work:
...
.directive('tdCard', ['$timeout', function($timeout) {
return {
restrict: 'E',
template: '
',
require: '^tdCards',
transclude: true,
scope: {
onCardSwipe: '&',
onDestroy: '&'
},
compile: function(element, attr) {
return function($scope, $element, $attr, swipeCards) {
var el = $element[0];
*** the last argument 'swipeCards' is always undefined. **
I've also tried the original fork for swipe-cards and the same issue there. How is anyone making this work? baffling.. so little code , not much to debug. but 'swipeCards' argument is always undefined.
Can anyone throw me a bone?
my HTML is exactly from the demo (but i added some real cards)
.controller('CardsCtrl', function($scope, TDCardDelegate) {
console.log('CARDS CTRL');
var cardTypes = [{
title: 'Swipe down to clear the card',
image: '/vendor/ionic-contrib-swipe-cards/example/www/img/pic.png'
}, {
title: 'Where is this?',
image: '/vendor/ionic-contrib-swipe-cards/example/www/img/pic.png'
}, {
title: 'What kind of grass is this?',
image: '/vendor/ionic-contrib-swipe-cards/example/www/img/pic2.png'
}, {
title: 'What beach is this?',
image: '/vendor/ionic-contrib-swipe-cards/example/www/img/pic3.png'
}, {
title: 'What kind of clouds are these?',
image: '/vendor/ionic-contrib-swipe-cards/example/www/img/pic4.png'
}];
$scope.cards = Array.prototype.slice.call(cardTypes, 0);
$scope.cardSwiped = function(index) {
$scope.addCard();
};
$scope.cardDestroyed = function(index) {
$scope.cards.splice(index, 1);
};
$scope.addCard = function() {
var newCard = cardTypes[Math.floor(Math.random() * cardTypes.length)];
newCard.id = Math.random();
$scope.cards.push(angular.extend({}, newCard));
}
})
.controller('CardCtrl', function($scope, TDCardDelegate) {
$scope.goAway = function() {
var card = TDCardDelegate.getSwipebleCard($scope);
card.swipe();
};
})