您的位置:首页技术文章
文章详情页

javascript - 点击select框选项 弹出ngDialog 点击取消的时候 关闭弹出框 希望select框的值不变

【字号: 日期:2024-03-09 11:29:09浏览:14作者:猪猪

问题描述

标题文字 ##下边是我的代码,点击取消后,select框的值依然会改变

//views< select 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类型将会清空预提明细,是否继续?’);}

标签: JavaScript
相关文章: