javascript - 點選select框選項 彈出ngDialog 點選取消的時候 關閉彈出框 希望select框的值不變
怪我咯
怪我咯 2017-05-16 13:19:18
0
1
946

標題文字 ##下邊是我的程式碼,點擊取消後,select框的值仍然會改變

//views
< select class="mei-select mei-select-md" ng-model="nextparam.emscaapportionh.imp_erp_type" ng-options="m.itemValue as m.itemName for m in impErpTypes" ng-disabled="!isErpTypeEdit" ng-change="impErpTypeChange()" > </select >
//ngDialogCtrl

(function () {
    'use strict';
    angular.module('app')
        .controller("ngDialogCtrl", ['$scope',
            function ($scope) {
                $scope.msg = $scope.dialog ? $scope.dialog.msg : '确认要执行吗?';
            }
        ]);
})();
//业务逻辑
$scope.openConfirmDialog = function (callback, msg) {
$scope.dialog = {
        msg: msg
    };
    ngDialog.openConfirm({
        template: 'app/app_common/views/ngdialog.confirm.html',
        plain: false,
        showClose: true,
        closeByDocument: true,
        closeByEscape: true,
        scope: $scope,
        width: '20%',
        controller: 'ngDialogCtrl'
    }).then(callback);
};

 //修改导ERP类型
$scope.impErpTypeChange = function () {
    var impErpTypeChangeFun = function () {
        $scope.budgetGridOptions.data = [];
    };
    $scope.openConfirmDialog(impErpTypeChangeFun, '更改导类型将会清空明细,是否继续?');
}
怪我咯
怪我咯

走同样的路,发现不同的人生

全部回覆(1)
伊谢尔伦

看了ngDialog api,加多一個preCloseCallback屬性即可

       $scope.openConfirmDialog = function (callback, closeCallback ,msg) {
                    $scope.dialog = {
                        msg: msg
                    };
                    ngDialog.openConfirm({
                        template: 'app/app_common/views/ngdialog.confirm.html',
                        plain: false,
                        showClose: true,
                        closeByDocument: true,
                        closeByEscape: true,
                        scope: $scope,
                        width: '20%',
                        controller: 'ngDialogCtrl',
                        preCloseCallback:closeCallback,
                    }).then(callback);
                }

                //修改导ERP类型
                $scope.oldImpErpType = $scope.nextparam.emscaapportionh.imp_erp_type;
                $scope.impErpTypeChange = function(){
                    var impErpTypeChangeFun = function () {
                         $scope.$emit("changeImpErpType");
                    };
                    var closeFun = function(){
                        $scope.nextparam.emscaapportionh.imp_erp_type = $scope.oldImpErpType;
                    }
                    $scope.openConfirmDialog(impErpTypeChangeFun, closeFun,'更改导ERP类型将会清空预提明细,是否继续?');
                }

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板