Angular Revertible Action
Example use:
angular.module('xxx').controller 'TreasureController', ($scope, treasureId, RevertibleAction, Restangular) ->
Restangular.one('treasure', treasureId).get().then (treasure) ->
$scope.treasure = treasure
$scope.deleteTreasure = ->
treasureBackup = $scope.treasure
delete $scope.treasure
RevertibleAction(
'You have deleted your treasure' # the message to display in the undo notification
Restangular.one('treasure', treasureId).remove # the callback to execute after confirmation (clicking OK or after a delay)
)
# now, the notification appears and waits for reaction
.then ->
# executes after successfull callback
alert 'Your treasure is gone!'
.catch ->
# executes if callback failed or the action has been undone
alert 'Your treasure removal is undone!'
$scope.treasure = treasureBackup
Dependencies: