加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AngularJS:关闭模态时的函数调用

发布时间:2020-12-17 17:45:51 所属栏目:安全 来源:网络整理
导读:我想这是一个非常简单的答案,但我找不到合适的语法. 我的模态开口是这样的, $scope.assignment = function (groupId) { var modalInstance = $modal.open({ templateUrl: 'assignment_form',controller: 'GroupsAssignmentController',windowClass: 'modal-u
我想这是一个非常简单的答案,但我找不到合适的语法.

我的模态开口是这样的,

$scope.assignment = function (groupId) {
    var modalInstance = $modal.open({
        templateUrl: 'assignment_form',controller: 'GroupsAssignmentController',windowClass: 'modal-user-window',resolve: {
            id: function () {
                return groupId;
            }
        }
    });

我想要做的就是在模态关闭时运行一个函数,这样我的主屏幕就会更新.

我不确定这是否涉及$modal.close?

$modal.close({
    //getAllGroups();
    });

解决方法

modalInstance.result.finally(function(){ 
    // do your work here
});

你也可以使用

then(successCallback,errorCallback,notifyCallback)

当承诺得到解决时,SuccessCallback超越了.拒绝承诺时执行errorCallback.最后通知notifyCallback.

在angular-ui模态的情况下,单击背景将导致拒绝承诺.考虑到这一点,您的代码可以更改为:

modalInstance.result.then(function () {
  alert('Modal success');
},function () {
  alert('Modal dismissed');
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读