How to Select multiple item on long press?


#1

How to select the multiple item on long press ??

<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="chat in chats" type="item-text-wrap" ng-click="multicheck(chat)" on-hold="onHold()">
                <img ng-src="img/{{chat.Image1}}">
                <h2>{{chat.name}}</h2>
                <div class="item-text-wrap">
                    <h4>{{chat.lastText}}</h4>
</div>
</ion-item>

#2

any solution to this question? i have the same question :expressionless:


#3

Hi adityajaiz,

If your main goal is to select multiple list items only then there is a way to do it without longpress ( on-hold ) event.

You just need to use the ng-click directive:

<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="chat in chats" type="item-text-wrap" ng-click="multicheck(chat)" on-hold="onHold()" ng-class="{ active: chat.selected }">
                <img ng-src="img/{{chat.Image1}}">
                <h2>{{chat.name}}</h2>
                <div class="item-text-wrap">
                    <h4>{{chat.lastText}}</h4>
</div>
</ion-item>

controller:

var selected = [];

$scope.multicheck = function (user) {
    var index = selected.indexOf(user);
    if(index > -1) {
        selected.splice(index, 1);
        user.selected = false;
    } else {
        selected.push(member);
        user.selected = true;
    }
}

Hope this will solve your problem.


How to select multi itmems for batch action for various items in ng-collection?
#4

Add class activated , this will help you out.
Then change the required CSS accordingly.

<ion-item class="item-remove-animate item-avatar item-icon-right activated">