diff --git a/src/stateDirectives.js b/src/stateDirectives.js index 964ddc420..0a66185f0 100644 --- a/src/stateDirectives.js +++ b/src/stateDirectives.js @@ -372,6 +372,8 @@ function $StateRefActiveDirective($state, $stateParams, $interpolate) { function removeClass(el, className) { el.removeClass(className); } function anyMatch(state, params) { return $state.includes(state.name, params); } function exactMatch(state, params) { return $state.is(state.name, params); } + + update(); }] }; } diff --git a/test/stateDirectivesSpec.js b/test/stateDirectivesSpec.js index f0271615d..7af62ba99 100644 --- a/test/stateDirectivesSpec.js +++ b/test/stateDirectivesSpec.js @@ -680,6 +680,16 @@ describe('uiSrefActive', function() { expect(el[0].className).toMatch(/admin/); expect(el[0].className).not.toMatch(/contacts/); })); + + it('should update the active classes when compiled', inject(function($compile, $rootScope, $document, $state, $q) { + $state.transitionTo('admin.roles'); + $q.flush(); + timeoutFlush(); + el = $compile('
')($rootScope); + $rootScope.$digest(); + timeoutFlush(); + expect(el.hasClass('active')).toBeTruthy(); + })); }); });