Option-buttons in ion-list not working in 0.9.25


#1

Hello. I had to use 0.9.25 ionic bundle due to 0.9.24 not working for the todo demo. I decided to modify the demo to add the ability to check an item in the list as done. I also wanted the ability to delete an item from the list by using a swipe left gesture. I added option-buttons to the ion-list element, specified my button options (an array with a single element) as follows, and I see the button but clicking it does not pass the item into the onTap method. The “markCompleted” method works and the conditional checkmark indicating that this is completed or not functions as well.

Any clue as to what I’m doing wrong would be appreciated. Thank you.

    <ion-list option-buttons="deleteItemButton">
      <ion-item ng-repeat="task in activeProject.tasks" ng-click="markCompleted($index)">
        {{task.title}}
        <i ng-hide="!task.checked" style="float: right" class="icon ion-checkmark"></i>
      </ion-item>
    </ion-list>

$scope.deleteItemButton = [
{
text: ‘Delete’,
type: ‘button-assertive’,
onTap: function(item) {
alert('Edit Item: ’ + item.id);
}
}];


#2

I figured out what I was doing wrong. The documentation shows the following syntax with an additional item=“item” and I didn’t pickup on that. The correct ion-item line should look like:

<ion-item ng-repeat=“task in activeProject.tasks” item="item" ng-click=“markCompleted($index)”>

The value passed to “item” is passed to the onTap function.