diff --git a/src/modal/docs/readme.md b/src/modal/docs/readme.md index 2e69a34a8f..44dd951ce4 100644 --- a/src/modal/docs/readme.md +++ b/src/modal/docs/readme.md @@ -11,6 +11,7 @@ The `$modal` service has only one method: `open(options)` where available option * `backdrop` - controls presence of a backdrop. Allowed values: true (default), false (no backdrop), `'static'` - backdrop is present but modal window is not closed when clicking outside of the modal window. * `keyboard` - indicates whether the dialog should be closable by hitting the ESC key, defaults to true * `windowClass` - additional CSS class(es) to be added to a modal window template +* `windowTemplateUrl` - a path to a template overriding modal's window template The `open` method returns a modal instance, an object with the following properties: diff --git a/src/modal/modal.js b/src/modal/modal.js index f60eadb243..6809c41825 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -83,7 +83,9 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition']) }, replace: true, transclude: true, - templateUrl: 'template/modal/window.html', + templateUrl: function(tElement, tAttrs) { + return tAttrs.templateUrl || 'template/modal/window.html'; + }, link: function (scope, element, attrs) { element.addClass(attrs.windowClass || ''); @@ -226,10 +228,12 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition']) } var angularDomEl = angular.element('
'); - angularDomEl.attr('window-class', modal.windowClass); - angularDomEl.attr('index', openedWindows.length() - 1); - angularDomEl.attr('animate', 'animate'); - angularDomEl.html(modal.content); + angularDomEl.attr({ + 'template-url': modal.windowTemplateUrl, + 'window-class': modal.windowClass, + 'index': openedWindows.length() - 1, + 'animate': 'animate' + }).html(modal.content); var modalDomEl = $compile(angularDomEl)(modal.scope); openedWindows.top().value.modalDomEl = modalDomEl; @@ -353,7 +357,8 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition']) content: tplAndVars[0], backdrop: modalOptions.backdrop, keyboard: modalOptions.keyboard, - windowClass: modalOptions.windowClass + windowClass: modalOptions.windowClass, + windowTemplateUrl: modalOptions.windowTemplateUrl }); }, function resolveError(reason) { diff --git a/src/modal/test/modalWindow.spec.js b/src/modal/test/modalWindow.spec.js index 6c9ce8d29b..3334cdbf54 100644 --- a/src/modal/test/modalWindow.spec.js +++ b/src/modal/test/modalWindow.spec.js @@ -16,4 +16,14 @@ describe('modal window', function () { expect(windowEl).toHaveClass('test'); expect(windowEl).toHaveClass('foo'); }); + + it('should support custom template url', inject(function($templateCache) { + $templateCache.put('window.html', '
'); + + var windowEl = $compile('
content
')($rootScope); + $rootScope.$digest(); + + expect(windowEl).toHaveClass('mywindow'); + expect(windowEl).toHaveClass('test'); + })); }); \ No newline at end of file