1. html文件
ng-if="data.myFollowData.length!=0" on-release="action.onRelease()">
ng-click="action.delete(item)">
2. controller文件
myFollow.trashIsShow = false;
$scope.data.listCanSwipe = true;
//定义动作
$scope.action = {};
// 跳到对应详情页
$scope.action.toDetailPage = function (object) {
if ($scope.data.listCanSwipe && !myFollow.buttonOption) {
...
...
}
};
//当用户结束触摸事件时触发
$scope.action.onRelease = function () {
myFollow.trashIsShow = true;
$scope.data.listCanSwipe = !$scope.data.listCanSwipe;
};
//删除当前列表项
$scope.action.delete = function (item) {
deleteMyFollow(item);
};
//隐藏删除按钮
$scope.action.hideTrash = function () {
myFollow.trashIsShow = false;
$ionicListDelegate.closeOptionButtons();
};
//======删除关注接口======
function deleteMyFollow(item) {
var deleteFollow = {
object_id: item.id
};
MrTrustResource.Follow.delete(deleteFollow).$promise.then(function (indata) {
myFollow.trashIsShow = false;
$scope.data.myFollowData.splice($scope.data.myFollowData.indexOf(item), 1);
}, function (rejection) {
$ionicLoading.show({
template: '
noBackdrop: false
});
$timeout(function () {
$ionicLoading.hide();
}, 2000);
}).finally(function () {
// todo
});
}