如果存在多个模态,模态弹出窗口不会关闭

时间:2015-05-14 11:24:50

标签: javascript angularjs twitter-bootstrap angular-ui-bootstrap

我有三种不同的控制器和视图

单击按钮时从屏幕开始Modal1

$modal.open({
    templateUrl: 'abc.html',
    controller: 'abcCtrl',
    size: 'lg',
    scope: $scope,
});

在modal1中有下一个按钮等单击下一步按钮想要关闭Modal1并打开Modal2

$scope.validate = function(isValid) {
    if (!isValid) {
        $scope.errors = 'Please fill-up required fields';
    } else {
        $scope.errors = '';
        $modal.open({
            templateUrl: 'Payment.html',
            controller: 'PaymentCtrl',
            size: 'lg',
            scope: $scope,
        });
    }
};

在modal2中有下一个按钮等单击下一个按钮想要关闭Modal2并打开Modal3

$scope.placeOrder = function() {
        $scope.cart.abc().then(function(result) {
                $modal.open({
                    templateUrl: 'orderSummary.html',
                    controller: 'SummaryCtrl',
                    size: 'lg',
                    scope: $scope,
                    resolve: {
                        items: function() {
                            return result.data;
                        }
                    }
                });
            },
            function(err) {
                //error msg
            });
};

如果我将$ modalInstance.close添加到Modal1 打开Modal2的另一个模态,Modal1已关闭,Modal2已打开但没有一个按钮工作。 Modal3没有打开不知道实际问题发生了什么。

请帮帮我。提前谢谢。

2 个答案:

答案 0 :(得分:0)

好像你正在寻找巫师...

看看tmhOAuth

答案 1 :(得分:0)

从主控制器首先打开你的Modal1,关闭Modal1,即

 var modalInstance = $modal.open({
                templateUrl: 'abc',
                controller: 'abcCtrl',
                size: 'lg',
                scope: $scope,
             });

            modalInstance.result.then(function(result) {
                  $scope.def();
              }, function(err) {
                //
            });

  $scope.def = function(){
     //open another 
    }

调用另一个函数并在该函数中打开另一个模态,同样你可以这样做。