Angularjs在模态上确认对话模态

时间:2014-08-07 05:50:44

标签: angularjs

我正在使用Bootstrap模式。我目前正在以模态显示一些信息。如果用户点击模式上的Cancel,我想在其上显示确认模式。我怎样才能做到这一点?

以下是我的示例代码:

angular.module('modalApp', ['ui.bootstrap']);
var ModalDemoCtrl = function ($scope, $modal, $log) {

    $scope.items = ['item1', 'item2', 'item3'];

    $scope.open = function (size) {

        var modalInstance = $modal.open({
            templateUrl: 'templates/myModalContent.html',
            controller: ModalInstanceCtrl,
            size: size,
            resolve: {
                items: function () {
                    return $scope.items;
                }
            }
        });

        modalInstance.result.then(function (selectedItem) {
            $scope.selected = selectedItem;
        }, function () {
            $log.info('Modal dismissed at: ' + new Date());
        });
    };
};


var ModalInstanceCtrl = function ($scope, $modalInstance, items) {

    $scope.items = items;
    $scope.selected = {
        item: $scope.items[0]
    };

    $scope.ok = function () {
        $modalInstance.close($scope.selected.item);
    };

    $scope.cancel = function () {
        if(confirm('Do you want to continue')) {
            alert('ok');
        } else {
            $modalInstance.dismiss('cancel');
        }

    };
};

在Javascript确认的地方,我想显示另一个bootstrap模态确认。

0 个答案:

没有答案