I'm working on an Ionic project and have a ng-repeat directive that lists all messages objects inside the DOM:
<div ng-repeat="messages in allMessages" class="single-ng-repeat">
<div class="bubble"
ng-init="messages.isgray = false"
ng-class="{'bg-gray' : item.isgray}"
on-hold="item.isgray =!item.isgray; onholdSelectMessages(item.isgray, messages);"
ng-class="'messageClass-' + message.id">
<img class="bubble-image" ng-src="{{messages.message}}" ng-click="openImage(messages.message);" />
</div>
</div>
So what I made until now is that the style bg-gray is added to the object when the user Ionic on-hold event is triggered.
That works fine. When a user holds the finger on the object for one second, it changes its background color to gray, and when he does it again, it changes its background color to default white. So, the point is, that when the background of the message is set to gray, the message is selected.
So now for example, a user has 20 messages in that list. I want to make a functionality, so that he can select 5 of these 20 messages and save it inside an Angular service. So the user should have the ability to select (on-hold) the 1st message and the 5th message, and all the messages in between should be selected, too. So automatically the messages 2,3 and 4 should have a gray background color, too.
Any help would be appreciated.
Thanks.