-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using ui-sref-active[-eq] with ng-repeat causes a race condition #1997
Comments
Sidenote: |
Good point. Still, I was just illustrating that in some conditions the the DOM is ready while in some it's not. In my own code, there are no extra directives on the |
I just got to this as we needed this very functionality and were running 0.2.13 While this solves part of the issue, it does not work for truly dynamic data - ui-sref elements will push to ui-sref-active[-eq], but do nothing when $destroy-ed |
No longer using |
As the title states, when using
ui-sref-active
orui-sref-active-eq
on a dynamically generated element, such as one created viang-repeat
, the element is not always ready for classes to be applied when$stateChangeSuccess
is fired. This causes the classes to not apply on the initial state load, but they are applied on subsequent state changes.Sample markup:
Although UI Router matches the state properly, the
update()
fails to apply the classes as$element
is not yet available on the DOM.In the above code, removing the
{{nav.classes}}
resolves the issue, which leads me to believe it's simply a race condition between the DOM and UI Router. Wrapping the$element.addClass(activeClass)
in a$timeout
resolves the issue, though it causes numerous unit tests to fail.The text was updated successfully, but these errors were encountered: