From 50a561a16bc538c8f895f6abfc268fe6e5084cbc Mon Sep 17 00:00:00 2001 From: raymMM Date: Fri, 5 Jun 2015 13:08:08 +0200 Subject: [PATCH] Update modal.js Proposed solution for https://github.com/angular-ui/bootstrap/issues/3765 --- src/modal/modal.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/modal/modal.js b/src/modal/modal.js index 9470f62d5c..a1f28cc2bd 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -303,10 +303,24 @@ angular.module('ui.bootstrap.modal', []) angularDomEl.attr('modal-animation', 'true'); } + var hasParent = modal.futureParentEl && modal.futureParentEl.append; + + if (hasParent) { + modal.futureParentEl.append(angularDomEl); + } + var modalDomEl = $compile(angularDomEl)(modal.scope); openedWindows.top().value.modalDomEl = modalDomEl; openedWindows.top().value.modalOpener = modalOpener; - body.append(modalDomEl); + + if (hasParent) { + //defer adding to body in order to ensure that the element is compiled completely in the parent. Required directive controllers will be found in the hierarchy of the parentElement + $timeout(function () { + body.append(modalDomEl); + }); + } else { + body.append(modalDomEl); + } body.addClass(OPENED_MODAL_CLASS); }; @@ -445,6 +459,7 @@ angular.module('ui.bootstrap.modal', []) deferred: modalResultDeferred, renderDeferred: modalRenderDeferred, content: tplAndVars[0], + futureParentEl: modalOptions.futureParentEl, animation: modalOptions.animation, backdrop: modalOptions.backdrop, keyboard: modalOptions.keyboard,