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

Commit

Permalink
fix(modal): add a work-around for transclusion scope
Browse files Browse the repository at this point in the history
Fixes #2110
Closes #2134
Closes #2143
  • Loading branch information
pkozlowski-opensource committed May 5, 2014
1 parent d7c314e commit 0b31e86
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/modal/modal.js
Expand Up @@ -110,6 +110,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
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
@@ -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>

0 comments on commit 0b31e86

Please sign in to comment.