Angularjs Bootstrap模态框关闭调用在点击外部/按下esc键时。

29 浏览
0 Comments

Angularjs Bootstrap模态框关闭调用在点击外部/按下esc键时。

我在项目中使用了Angular-ui/bootstrap模态框。

这是我的模态框代码:

$scope.toggleModal = function () {
    $scope.theModal = $modal.open({
        animation: true,
        templateUrl: 'pages/templates/modal.html',
        size: "sm",
        scope: $scope
    });
}

可以通过点击ESC按钮或点击模态框外部区域关闭模态框。有没有办法在这种情况下运行一个函数?我不太确定如何捕捉这种关闭事件。

我知道我可以通过添加一个ng-click="closeModal()"来手动关闭模态框,代码如下:

$scope.closeModal = function () {
    $scope.theModal.dismiss('cancel');
};

0