Opening modal from popup

I am trying to open Modal window from already opened popup. It is relatively straight froward if both popup and modal originated from the same Controller. But in this case, the modal about to open is from directive and it has its own isolated scope scope:{}.
The problem is after the modal is opened, the popup need to close programatically or otherwise. When the popup is closed, it trigger the $scope.$on(’$destroy’,function(){}) event and the already opened modal is forced to close to clear the memory, according to the documentation.

    $scope.$on('$destroy', function() {

I believe, both modal and popup are sharing the same $scope, therefore when the popup is closed (after the modal is opened), it trigger the $scope.$on(’$destory’,function(){}) on its own scope which is shared with the opened modal.

Please check out the codepen link to see the problem I am encountering. Any help or suggestion will be appreciated.