diff options
| author | Tobias Bosch | 2013-12-10 16:46:29 -0800 |
|---|---|---|
| committer | Tobias Bosch | 2013-12-12 17:18:44 -0800 |
| commit | 30a8b7d0b5d4882c2bf3b20eb696a02f5b667726 (patch) | |
| tree | 0c40067e5142a8a1dc71df8b03b39fb3e05b2878 /test/ng/directive | |
| parent | f8944efe70b81e02704df9b53ea2546c80c73d3b (diff) | |
| download | angular.js-30a8b7d0b5d4882c2bf3b20eb696a02f5b667726.tar.bz2 | |
fix(ngInclude): Add template to DOM before linking other directives
The template needs to be added to the DOM before
other directives at the same element as `ngInclude` are linked.
Fixes #5247.
Diffstat (limited to 'test/ng/directive')
| -rw-r--r-- | test/ng/directive/ngIncludeSpec.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 2d115e8b..9e0a47b0 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -524,6 +524,46 @@ describe('ngInclude and transcludes', function() { }); }); + + it('should link directives on the same element after the content has been loaded', function() { + var contentOnLink; + module(function() { + directive('test', function() { + return { + link: function(scope, element) { + contentOnLink = element.text(); + } + }; + }); + }); + inject(function($compile, $rootScope, $httpBackend) { + $httpBackend.expectGET('include.html').respond('someContent'); + element = $compile('<div><div ng-include="\'include.html\'" test></div>')($rootScope); + $rootScope.$apply(); + $httpBackend.flush(); + expect(contentOnLink).toBe('someContent'); + }); + }); + + it('should add the content to the element before compiling it', function() { + var root; + module(function() { + directive('test', function() { + return { + link: function(scope, element) { + root = element.parent().parent(); + } + }; + }); + }); + inject(function($compile, $rootScope, $httpBackend) { + $httpBackend.expectGET('include.html').respond('<span test></span>'); + element = $compile('<div><div ng-include="\'include.html\'"></div>')($rootScope); + $rootScope.$apply(); + $httpBackend.flush(); + expect(root[0]).toBe(element[0]); + }); + }); }); describe('ngInclude animations', function() { |
