Close bootstrap model popup from another controller

379 views Asked by At

Hi i have a controllerA which generate a form based on some URL parameters and after submitting that form some some action will be performed. Now i have created another controllerB and in that i have created a button. upon clicking on that button one model popup will be opened which contains controllerA url as iframe src. In that model popup i'm able to see the form generated. After submitting that form i have to close the model popup.

controllerA

  - Contains some logic to generate form

controllerB

  - Contains a model popup with embed iframe. iframe src as controllerA URL

Here is my question How can i close that model afer submitting the form?

Here is sample code:

this code contains in controllerB

  $scope.addmemPopup = function() {
        $scope.showpopup = $modal.open({
            templateUrl: 'addmem.tpl.html',
            size: 'lg',
            backdrop: 'static',
            keyboard: false,
            windowClass: 'add-mem'
        });
  }

  $scope.getIframeurl = function() {
        return '#/genmem/?mem_id='+$scope.mem.id+'&z_id=' + $scope.mem.zip;
  };
  $scope.hidePopup = function() {
        $scope.showpopup .close();
  };

In controllerA i have a method to submit the form. after submitting the form how can i close the above popup which is rendered from controllerB.

I think hopefully i explained correctly. please help me in resolving this. Thanks in advance.

1

There are 1 answers

3
QI.soa On

What's the relationship between controllerA and controllerB?
if controllerB is the parent controller,you can use $scope.$emit('event:close') in controllerA and receive this event in controllerB with

$scope.$on('event:close',function(evt) {
   $scope.showpopup.close();
})