I'm trying to randomly generate a list, in which every item is clickable.
<ul class="list-group">
<li class="list-group-item" ng-repeat="user in users | orderBy: random" ng-class="user.value && user.color" ng-click="changeValue(user)"> </li>
</ul>
So, on click I want it to change the value of the item and also the colour.
I already can randomly generate the list with the following function:
$scope.random = function() {
return 0.5 - Math.random();
};
The problem I'm facing is that whenever I click a list item, they re-arrange randomly. I want them to display randomly at the beginning and then stay in the exact same order after I click them. How can I avoid the re-arrange?
Here's a plunker with a practical example:
Thank you.
Aucun commentaire:
Enregistrer un commentaire