diff --git a/src/ng/compile.js b/src/ng/compile.js index 85728ea01315..9123d8f7815c 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1654,7 +1654,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { previousCompileContext = previousCompileContext || {}; var terminalPriority = -Number.MAX_VALUE, - newScopeDirective, + newScopeDirective = previousCompileContext.newScopeDirective, controllerDirectives = previousCompileContext.controllerDirectives, newIsolateScopeDirective = previousCompileContext.newIsolateScopeDirective, templateDirective = previousCompileContext.templateDirective, @@ -1820,6 +1820,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { nodeLinkFn = compileTemplateUrl(directives.splice(i, directives.length - i), $compileNode, templateAttrs, jqCollection, hasTranscludeDirective && childTranscludeFn, preLinkFns, postLinkFns, { controllerDirectives: controllerDirectives, + newScopeDirective: (newScopeDirective !== directive) && newScopeDirective, newIsolateScopeDirective: newIsolateScopeDirective, templateDirective: templateDirective, nonTlbTranscludeDirective: nonTlbTranscludeDirective diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 794a95a48ebf..f8e42da02110 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2370,7 +2370,7 @@ describe('$compile', function() { }) ); - it('should not allow more then one isolate scope creation per element', inject( + it('should not allow more than one isolate scope creation per element', inject( function($rootScope, $compile) { expect(function() { $compile('
'); @@ -2379,6 +2379,18 @@ describe('$compile', function() { }) ); + it('should not allow more than one isolate/new scope creation per element regardless of `templateUrl`', + inject(function($httpBackend) { + $httpBackend.expect('GET', 'tiscope.html').respond('
Hello, world !
'); + + expect(function() { + compile('
'); + $httpBackend.flush(); + }).toThrowMinErr('$compile', 'multidir', 'Multiple directives [scopeB, tiscopeA] ' + + 'asking for new/isolated scope on:
'); + }) + ); + it('should not allow more than one isolate scope creation per element regardless of directive priority', function() { module(function($compileProvider) { $compileProvider.directive('highPriorityScope', function() {