Hi there,
I’m trying to use ActionSheet to delete task on my app. ActionSheet slides in fine and all that, but I can’t figure out how to make the ‘Delete’ button actually work.
$scope.showActionsheet = function (task) {
$ionicActionSheet.show({
titleText: 'What you wanna do with this task?',
buttons: [
{
text: 'Edit <i class="icon ion-ios7-compose-outline" i>'
},
],
destructiveText: 'Delete',
cancelText: 'Cancel',
cancel: function () {
console.log('CANCELLED');
},
buttonClicked: function (index) {
console.log('BUTTON CLICKED', index);
if (index = 0) {
alert("Edit button");
}
return true;
},
destructiveButtonClicked: function (task) {
// Is it here where I should do it?
return true;
}
});
};
I’m not sure how should I provide the ‘task’ parameter to the action sheet in order to delete it.
I’ve got this function for deleting:
$scope.deletingTask = function (task) {
database.deleteTask(task.id).then(function () {
$scope.refreshList();
}, function (err) {
$window.alert(err);
});
$scope.tasks.splice($scope.tasks.indexOf(task), 1);
};
Thanks for your help