Skip to content

Commit

Permalink
Update modal.js
Browse files Browse the repository at this point in the history
Proposed solution for angular-ui#3765
  • Loading branch information
raymMM committed Jun 5, 2015
1 parent 83c4266 commit 50a561a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 50a561a

Please sign in to comment.