From 7b0d59ef86cf5e734fb78992e28faa6aeeeeca61 Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Fri, 20 Sep 2013 11:04:37 -0700 Subject: [PATCH] fix(ngInclude): fix regression when ngInclude is present on an element with interpolated attributes Closes #3793 --- src/ng/directive/ngInclude.js | 1 + test/ng/directive/ngIncludeSpec.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/ng/directive/ngInclude.js b/src/ng/directive/ngInclude.js index 0f1f245c2bc1..c92ff808a5ef 100644 --- a/src/ng/directive/ngInclude.js +++ b/src/ng/directive/ngInclude.js @@ -153,6 +153,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile' function($http, $templateCache, $anchorScroll, $compile, $animate, $sce) { return { restrict: 'ECA', + priority: 500, terminal: true, transclude: 'element', compile: function(element, attr, transclusion) { diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index f1bfbba21c7c..d464403e831a 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -281,6 +281,32 @@ describe('ngInclude', function() { })); + it('should work when placed on an anchor link', inject(function($compile, $rootScope, $httpBackend) { + // regression #3793 + + element = $compile('
')($rootScope); + $httpBackend.expect('GET', 'url1').respond('template text 1'); + $rootScope.hrefUrl = 'fooUrl1'; + $rootScope.includeUrl = 'url1'; + $rootScope.$digest(); + $httpBackend.flush(); + expect(element.text()).toBe('template text 1'); + expect(element.find('a').attr('href')).toBe('#/fooUrl1'); + + $httpBackend.expect('GET', 'url2').respond('template text 2'); + $rootScope.includeUrl = 'url2'; + $rootScope.$digest(); + $httpBackend.flush(); + expect(element.text()).toBe('template text 2'); + expect(element.find('a').attr('href')).toBe('#/fooUrl1'); + + $rootScope.hrefUrl = 'fooUrl2'; + $rootScope.$digest(); + expect(element.text()).toBe('template text 2'); + expect(element.find('a').attr('href')).toBe('#/fooUrl2'); + })); + + describe('autoscoll', function() { var autoScrollSpy;