Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 26f0e5b

Browse files
committed
support custom additional templates that can be speficied to override the default template proivded by angular-confirm
1 parent a424c97 commit 26f0e5b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

angular-confirm.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ angular.module('angular-confirm', ['ui.bootstrap.modal'])
4242
title: 'Confirm',
4343
ok: 'OK',
4444
cancel: 'Cancel'
45-
}
45+
},
46+
additionalTemplates: {}
4647
})
4748
.factory('$confirm', ["$uibModal", "$confirmModalDefaults", function ($uibModal, $confirmModalDefaults) {
4849
return function (data, settings) {
@@ -51,6 +52,14 @@ angular.module('angular-confirm', ['ui.bootstrap.modal'])
5152

5253
data = angular.extend({}, settings.defaultLabels, data || {});
5354

55+
if(data.templateName){
56+
var customTemplateDefinition = settings.additionalTemplates[data.templateName];
57+
if(customTemplateDefinition != undefined) {
58+
settings.template = customTemplateDefinition.template;
59+
settings.templateUrl = customTemplateDefinition.templateUrl;
60+
}
61+
}
62+
5463
if ('templateUrl' in settings && 'template' in settings) {
5564
delete settings.template;
5665
}
@@ -73,6 +82,7 @@ angular.module('angular-confirm', ['ui.bootstrap.modal'])
7382
ngClick: '&',
7483
confirm: '@',
7584
confirmSettings: "=",
85+
confirmTemplateName: "=",
7686
confirmTitle: '@',
7787
confirmOk: '@',
7888
confirmCancel: '@'
@@ -110,6 +120,9 @@ angular.module('angular-confirm', ['ui.bootstrap.modal'])
110120
if (scope.confirmCancel) {
111121
data.cancel = scope.confirmCancel;
112122
}
123+
if (scope.confirmTemplateName){
124+
data.templateName = scope.confirmTemplateName;
125+
}
113126
$confirm(data, scope.confirmSettings || {}).then(onSuccess);
114127
} else {
115128
scope.$apply(onSuccess);

angular-confirm.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)