jameskleeh / angular-confirm

Confirmation modal dialog for AngularJS
Apache License 2.0
150 stars 75 forks source link

How call a custom trigger to dismiss a modal? #14

Closed tarsislima closed 9 years ago

tarsislima commented 9 years ago

I need call a scope function when the dismiss modal is called. Eg: When i click 'delete' action, a 'highlight' class is added to the row clicked then $confirm service is called, but when i dismiss the modal, i want remove this class.

Some ideia, to resolve this?

  $scope.selectedRow = null; 
    $scope.delete = function (item) {
        $scope.selectedRow = item.id;  //need set this to null when modal dismiss

        $confirm('Deseja realmente excluir este registro?')
            .then(function() {
                resource.delete(item.id).then(function (r) {
                  var index = $scope.items.indexOf(item);
                    $scope.items.splice(index, 1);
                });
            });
    }
jameskleeh commented 9 years ago

I'm not quite sure what you're asking here. The $confirm service returns a promise. If the person hits the OK button, the success function will be executed. If they hit cancel the error function will be executed.

$confirm().then(success, error)

tarsislima commented 9 years ago

That´s right, the 'return promise' escaped me at documentation. Ps: This service is very usefull, Thank´s a lot!