如果存在多个模式,模式弹出窗口不会关闭
Modal Popup not Closing if multiple Modals are present
我有三个不同的控制器和视图
单击按钮时从屏幕打开 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 已打开,但 none 个按钮有效。 Modal3 没有打开不知道实际发生了什么。
请帮帮我。提前致谢。
看来你在找精灵...
看看here
从主控制器首先打开您的 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
}
调用另一个函数,并在该函数中打开另一个模式,您也可以这样做。
我有三个不同的控制器和视图
单击按钮时从屏幕打开 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 已打开,但 none 个按钮有效。 Modal3 没有打开不知道实际发生了什么。
请帮帮我。提前致谢。
看来你在找精灵...
看看here
从主控制器首先打开您的 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
}
调用另一个函数,并在该函数中打开另一个模式,您也可以这样做。