From 0b31e8658e9a9520e8d5ccfcea23fa040f032562 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sun, 4 May 2014 14:35:38 +0200 Subject: [PATCH] fix(modal): add a work-around for transclusion scope Fixes #2110 Closes #2134 Closes #2143 --- src/modal/modal.js | 11 +++++++++++ src/modal/test/modalWindow.spec.js | 7 +++++++ template/modal/window.html | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/modal/modal.js b/src/modal/modal.js index d9eea88f01..043596484c 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -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) { diff --git a/src/modal/test/modalWindow.spec.js b/src/modal/test/modalWindow.spec.js index 3334cdbf54..6d33e5a0d3 100644 --- a/src/modal/test/modalWindow.spec.js +++ b/src/modal/test/modalWindow.spec.js @@ -9,6 +9,13 @@ describe('modal window', function () { $compile = _$compile_; })); + it('should not use transclusion scope for modals content - issue 2110', function () { + $compile('
')($rootScope); + $rootScope.$digest(); + + expect($rootScope.foo).toBeTruthy(); + }); + it('should support custom CSS classes as string', function () { var windowEl = $compile('
content
')($rootScope); $rootScope.$digest(); diff --git a/template/modal/window.html b/template/modal/window.html index 1e9a898646..81ca197ebb 100644 --- a/template/modal/window.html +++ b/template/modal/window.html @@ -1,3 +1,3 @@ \ No newline at end of file