Skip to content

Commit 6c3271a

Browse files
Merge pull request #2448 from fpipita/feature-1.0
fix(uiSrefActive): update the active classes when compiled
2 parents c1dc7fc + 2473e5c commit 6c3271a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/ng1/stateDirectives.ts

+1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ function $StateRefActiveDirective($state, $stateParams, $interpolate) {
329329

330330
function exactMatch(state, params) { return $state.is(state.name, params); }
331331

332+
update();
332333
}]
333334
};
334335
}

test/stateDirectivesSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -661,5 +661,15 @@ describe('uiSrefActive', function() {
661661
expect(el[0].className).toMatch(/admin/);
662662
expect(el[0].className).not.toMatch(/contacts/);
663663
}));
664+
665+
it('should update the active classes when compiled', inject(function($compile, $rootScope, $document, $state, $q) {
666+
$state.transitionTo('admin.roles');
667+
$q.flush();
668+
timeoutFlush();
669+
el = $compile('<div ui-sref-active="{active: \'admin.roles\'}"/>')($rootScope);
670+
$rootScope.$digest();
671+
timeoutFlush();
672+
expect(el.hasClass('active')).toBeTruthy();
673+
}));
664674
});
665675
});

0 commit comments

Comments
 (0)