Skip to content

Commit 50a561a

Browse files
committed
Update modal.js
Proposed solution for angular-ui#3765
1 parent 83c4266 commit 50a561a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Diff for: src/modal/modal.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,24 @@ angular.module('ui.bootstrap.modal', [])
303303
angularDomEl.attr('modal-animation', 'true');
304304
}
305305

306+
var hasParent = modal.futureParentEl && modal.futureParentEl.append;
307+
308+
if (hasParent) {
309+
modal.futureParentEl.append(angularDomEl);
310+
}
311+
306312
var modalDomEl = $compile(angularDomEl)(modal.scope);
307313
openedWindows.top().value.modalDomEl = modalDomEl;
308314
openedWindows.top().value.modalOpener = modalOpener;
309-
body.append(modalDomEl);
315+
316+
if (hasParent) {
317+
//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
318+
$timeout(function () {
319+
body.append(modalDomEl);
320+
});
321+
} else {
322+
body.append(modalDomEl);
323+
}
310324
body.addClass(OPENED_MODAL_CLASS);
311325
};
312326

@@ -445,6 +459,7 @@ angular.module('ui.bootstrap.modal', [])
445459
deferred: modalResultDeferred,
446460
renderDeferred: modalRenderDeferred,
447461
content: tplAndVars[0],
462+
futureParentEl: modalOptions.futureParentEl,
448463
animation: modalOptions.animation,
449464
backdrop: modalOptions.backdrop,
450465
keyboard: modalOptions.keyboard,

0 commit comments

Comments
 (0)