In the code it keeps recreating the instance, and never kills ..., inside the controller of the modal, it keeps executing the init again and again, ie it is not killing the instance, what would be the way to kill the instance, type already tried: modalInstance.$destroy()
, but says that method does not exist ...
$rootScope.displayItem = function (selected, size) {
$scope.send_itens = {
data:"Olá mundo!"
}
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'template.html',
controller: 'ModalController',
windowClass:'modal-window',
size: size,
backdrop: true,
keyboard: true,
resolve: {
dados: function () {
return $scope.send_itens;
}
}
});
modalInstance.result
.then(function (res) {
}, function () {
//quando fecha o modal
})
.catch(function(res) {
if (!(res === 'cancel' || res === 'escape key press')) {
// quando fecha por esc
}
})
.finally(function(){
//quando termina tudo
});
}
}