Skip to content

Commit 7b0d59e

Browse files
committed
fix(ngInclude): fix regression when ngInclude is present on an element with interpolated attributes
Closes angular#3793
1 parent d206f3d commit 7b0d59e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/ng/directive/ngInclude.js

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
153153
function($http, $templateCache, $anchorScroll, $compile, $animate, $sce) {
154154
return {
155155
restrict: 'ECA',
156+
priority: 500,
156157
terminal: true,
157158
transclude: 'element',
158159
compile: function(element, attr, transclusion) {

test/ng/directive/ngIncludeSpec.js

+26
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,32 @@ describe('ngInclude', function() {
281281
}));
282282

283283

284+
it('should work when placed on an anchor link', inject(function($compile, $rootScope, $httpBackend) {
285+
// regression #3793
286+
287+
element = $compile('<div><a ng-href="#/{{hrefUrl}}" ng:include="includeUrl"></a></div>')($rootScope);
288+
$httpBackend.expect('GET', 'url1').respond('template text 1');
289+
$rootScope.hrefUrl = 'fooUrl1';
290+
$rootScope.includeUrl = 'url1';
291+
$rootScope.$digest();
292+
$httpBackend.flush();
293+
expect(element.text()).toBe('template text 1');
294+
expect(element.find('a').attr('href')).toBe('#/fooUrl1');
295+
296+
$httpBackend.expect('GET', 'url2').respond('template text 2');
297+
$rootScope.includeUrl = 'url2';
298+
$rootScope.$digest();
299+
$httpBackend.flush();
300+
expect(element.text()).toBe('template text 2');
301+
expect(element.find('a').attr('href')).toBe('#/fooUrl1');
302+
303+
$rootScope.hrefUrl = 'fooUrl2';
304+
$rootScope.$digest();
305+
expect(element.text()).toBe('template text 2');
306+
expect(element.find('a').attr('href')).toBe('#/fooUrl2');
307+
}));
308+
309+
284310
describe('autoscoll', function() {
285311
var autoScrollSpy;
286312

0 commit comments

Comments
 (0)