angular-swing
angular-swing copied to clipboard
How to dynamically add card to stack?
I'm creating an initial stack of cards and want to add a new card at the bottom of the stack to replace a card that has been thrown out. Is there a way of achieving this?
Here is the function I'm using. Currently cards are being added at the top of the stack. Using $scope.stack.push instead of unshift also produces the same result.
$scope.addCard = function(name) {
$scope.stack.unshift({
'name': name
});
};
This works for me:
$scope.friends.unshift(friend);
I tried the same as @m10l mentioned, tried with push and also with unshift - it does not work
I found out, that it was because of "track by card.uid". Changed to "track by $index" - now it works as intended!
Track by $index and $scope.apply() helped me.