diff options
| author | Tobias Bosch | 2013-12-10 16:45:54 -0800 |
|---|---|---|
| committer | Tobias Bosch | 2013-12-12 17:18:44 -0800 |
| commit | f8944efe70b81e02704df9b53ea2546c80c73d3b (patch) | |
| tree | 6480df5a9b7a1ea65dabe3d2247c7e16fa9b8afb /test/ngRoute/directive/ngViewSpec.js | |
| parent | 43072e3812e32b89b97ad03144577cba50d4b776 (diff) | |
| download | angular.js-f8944efe70b81e02704df9b53ea2546c80c73d3b.tar.bz2 | |
fix(ngView): 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 `ngView` are linked.
Related to #5247.
Diffstat (limited to 'test/ngRoute/directive/ngViewSpec.js')
| -rw-r--r-- | test/ngRoute/directive/ngViewSpec.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ngRoute/directive/ngViewSpec.js b/test/ngRoute/directive/ngViewSpec.js index f4b28058..a8d1f459 100644 --- a/test/ngRoute/directive/ngViewSpec.js +++ b/test/ngRoute/directive/ngViewSpec.js @@ -582,6 +582,46 @@ describe('ngView and transcludes', function() { }); }); + + it('should link directives on the same element after the content has been loaded', function() { + var contentOnLink; + module(function($compileProvider, $routeProvider) { + $routeProvider.when('/view', {template: 'someContent'}); + $compileProvider.directive('test', function() { + return { + link: function(scope, element) { + contentOnLink = element.text(); + } + }; + }); + }); + inject(function($compile, $rootScope, $location) { + element = $compile('<div><div ng-view test></div>')($rootScope); + $location.url('/view'); + $rootScope.$apply(); + expect(contentOnLink).toBe('someContent'); + }); + }); + + it('should add the content to the element before compiling it', function() { + var root; + module(function($compileProvider, $routeProvider) { + $routeProvider.when('/view', {template: '<span test></span>'}); + $compileProvider.directive('test', function() { + return { + link: function(scope, element) { + root = element.parent().parent(); + } + }; + }); + }); + inject(function($compile, $rootScope, $location) { + element = $compile('<div><div ng-view></div>')($rootScope); + $location.url('/view'); + $rootScope.$apply(); + expect(root[0]).toBe(element[0]); + }); + }); }); describe('ngView animations', function() { |
