Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

fix(modal): add a work-around for transclusion scope #2143

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
};
}])

.directive('modalTransclude', function () {
return {
link: function($scope, $element, $attrs, controller, $transclude) {
$transclude($scope.$parent, function(clone) {
$element.empty();
$element.append(clone);
});
}
};
})

.factory('$modalStack', ['$transition', '$timeout', '$document', '$compile', '$rootScope', '$$stackedMap',
function ($transition, $timeout, $document, $compile, $rootScope, $$stackedMap) {

Expand Down
7 changes: 7 additions & 0 deletions src/modal/test/modalWindow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ describe('modal window', function () {
$compile = _$compile_;
}));

it('should not use transclusion scope for modals content - issue 2110', function () {
$compile('<div modal-window><span ng-init="foo=true"></span></div>')($rootScope);
$rootScope.$digest();

expect($rootScope.foo).toBeTruthy();
});

it('should support custom CSS classes as string', function () {
var windowEl = $compile('<div modal-window window-class="test foo">content</div>')($rootScope);
$rootScope.$digest();
Expand Down
2 changes: 1 addition & 1 deletion template/modal/window.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div tabindex="-1" role="dialog" class="modal fade" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)">
<div class="modal-dialog" ng-class="{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}"><div class="modal-content" ng-transclude></div></div>
<div class="modal-dialog" ng-class="{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}"><div class="modal-content" modal-transclude></div></div>
</div>