Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 40c0220

Browse files
matskomhevery
authored andcommitted
fix(ngView): ensure ngClass works with together with ngView's transclusion behavior
Closes: #3727
1 parent 36ad40b commit 40c0220

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

src/ngRoute/directive/ngView.js

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ function ngViewFactory( $route, $anchorScroll, $compile, $controller,
176176
return {
177177
restrict: 'ECA',
178178
terminal: true,
179+
priority: 1000,
179180
transclude: 'element',
180181
compile: function(element, attr, linker) {
181182
return function(scope, $element, attr) {

test/ngRoute/directive/ngViewSpec.js

+40
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,46 @@ describe('ngView animations', function() {
600600
expect(itemA).not.toEqual(itemB);
601601
var itemB = $animate.flushNext('enter').element;
602602
}));
603+
604+
it('should render ngClass on ngView',
605+
inject(function($compile, $rootScope, $templateCache, $animate, $location, $timeout) {
606+
607+
var item;
608+
$rootScope.tpl = 'one';
609+
$rootScope.klass = 'classy';
610+
element = $compile(html('<div><div ng-view ng-class="klass"></div></div>'))($rootScope);
611+
$rootScope.$digest();
612+
613+
$location.path('/foo');
614+
$rootScope.$digest();
615+
616+
item = $animate.flushNext('enter').element;
617+
618+
$animate.flushNext('addClass').element;
619+
$animate.flushNext('addClass').element;
620+
621+
expect(item.hasClass('classy')).toBe(true);
622+
623+
$rootScope.klass = 'boring';
624+
$rootScope.$digest();
625+
626+
$animate.flushNext('removeClass').element;
627+
$animate.flushNext('addClass').element;
628+
629+
expect(item.hasClass('classy')).toBe(false);
630+
expect(item.hasClass('boring')).toBe(true);
631+
632+
$location.path('/bar');
633+
$rootScope.$digest();
634+
635+
$animate.flushNext('leave').element;
636+
item = $animate.flushNext('enter').element;
637+
638+
$animate.flushNext('addClass').element;
639+
$animate.flushNext('addClass').element;
640+
641+
expect(item.hasClass('boring')).toBe(true);
642+
}));
603643
});
604644

605645
it('should not double compile when the route changes', function() {

0 commit comments

Comments
 (0)