Hi,

So, I've been trying to create a modal [delete] confirmation window 
directive, that when 'confirm' is pressed a waiting icon is displayed until 
the $http call [to delete the item] has been completed.

I think it works....but I don't know why the modal window dismisses itself 
without 
$modalInstance.close();


Detail:
I've followed this for the most part:
http://plnkr.co/edit/DgE5eGGmGebQfWunhqqv?p=preview
[Thanks khanhto <http://plnkr.co/users/khanhto>]


Then, I've added this to the ModalInstanceCtrl:


$scope.confirmDelete = function() {
          $scope.waiting = true;
          var promise = $scope.$parent.ngConfirmClick().then(function(ret){
              console.log("modal promise to callback function 
accepted...."+ret);
              //$modalInstance.close();
          }
          , function() {
              console.log("modal promise to callback function rejected?");
            }
          );
      };


ngConfirmClick is part of the directive and in this case is calling my 
event controller - in this case a function called removeEvent.

$scope.removeEvent = function(index)
    {
        var event = $scope.events[index];
        console.log("removeEvent");
        var defer = $q.defer();
        setTimeout(function() {
            defer.resolve('data received!'); 
          }, 1500);
        /*EventREST.remove(event)
        .then(function (item) {
              $scope.events.splice(index, 1); 
              defer.resolve('data received!'); 
              
        });*/
        return defer.promise;       
        
    }


So finally, the issue I'm having is that the modal window DOES NOT get 
dismissed when I use a setTimeout test (as above), but DOES get dismissed 
when I actually make a call to my service. In both cases as above, 
modalInstance.close() is commented out.

Any suggestions?

(Also I'm new to AngularJS, so if anyone can suggest a better way to do 
this, then please comment.)


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to