在与模态关联的控制器中(您可以使用“AnotherCtrl”或“模态”),您可以使用
$scope.$on()
使用
'modal.closing'
事件
例子:
var modalInstance = $uibModal.open({
templateUrl: 'a-template.html',
controller: ['$scope', function($scope){
$scope.$on('modal.closing', function(event, reason, closed){
if('condition for not closing')
event.preventDefault(); //You can use this to prevent the modal from closing
else
window.location = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";
});
}],
controllerAs: 'modal',
backdrop: false,
size: 'lg'
});