【发布时间】:2014-10-16 05:52:28
【问题描述】:
我正在使用Angular UI bootstrap modal dialog 并在服务中创建它:
myApp.factory('ModalService', ['$modal', function($modal) {
return {
trigger: function(template) {
$modal.open({
templateUrl: template,
size: 'lg',
controller: function($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.close($scope.selected.item);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
}
});
},
close: function() {
// this should close all modal instances
}
};
}]);
从控制器或其他任何方式调用 ModalService.close() 时,如何关闭所有模式实例?
【问题讨论】:
-
我非常感谢这篇文章。我能够通过它重构我的代码。唯一的区别是我确实使用了类似于文档的解析方法来获取我正在更新的数据。
标签: angularjs angular-ui angular-ui-bootstrap angularjs-service