-
Notifications
You must be signed in to change notification settings - Fork 3k
ui-router doesn't run the current state if your ui-view is inside an ng-include #679
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
Comments
Would you mind creating a plunkr that recreates the issue? |
I would, but I don't know how to do an ng-include in plunker. On Friday, December 13, 2013, Tim Kindberg wrote:
|
Ok I modified the example plunker to show what I mean. I noticed that if there are any ui-sref directives on the main page, the problem doesn't arise. |
Btw, the reason I'm not using ui-sref is because I need to have a link within a link. That is, an element is clickable and so is its parent element. This unfortunately can't be done with anchor tags. Is there a way to do this with ui-sref?
It makes more sense for the inner link to be the real link because it opens a different page, and you might want to use control-click on it. |
Why yes, you can: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-prevent-nested-ui-sref-objects-from-all-firingtriggering. There was an issue opened about this already, but we decided for now to just use the method shown in that link. Also that plunkr is working for me, am I supposed to see something break? |
Yes it's broken. It doesn't show an error or anything, but you can discover the oddity by experimenting with it a little. The bug is that ui-view or ui-sref tags in the included template (template.html) do not cause ui-router to start working. See how route1 is not rendered, even though it's supposed to redirect you there and render that immediately? If you add a single one of these tags to the outside template (index.html) it suddenly decides to redirect you and render the ui-view in the included template. I noticed a new oddity while I was making this plunker. In my initial bug report, I was reloading the page while the url already matched route1 and it wouldn't render the template. By playing with this, I've further discovered that it won't redirect you to route1 unless there are ui-view or ui-sref tags in the main template (index.html). |
The reason I'm doing a top level include is so my template can escape from the server-side templating engine, which uses the same mustache notation as angular. Unfortunately, it seems I need to put some ui-* directives outside the top level include in order to get ui-router to boot. |
Hmmm, that is quite interesting. If I add |
This sounded similar to angular/angular.js#4957 ...so I made a small modification to your plunkr whereby a run function block includes the $state service: http://plnkr.co/edit/a2lD1n?p=preview Does that work as expected? |
I ran into this same issue, and @dlukez suggestion fixed the issue. |
+1 to @dlukez fix |
Using @dlukez workaround, but would very much prefer the root cause fixed. |
+1 @dlukez fix but agree that the workaround should not be needed |
+1 @dlukez, also preferring the root cause fixed |
+1 Just ran into this (ng-include of template with ui-view being quietly ignored by ui-router)... Will try the workaround, but it seems preferable that what should work with kosher angular should also work with ui-router. |
@ericpeters0n last I checked this is also an issue in angular's ng-view |
+1 just ran into this while switching from ng-view to ui-view. |
I once tried fixing this for ng-view because it used to have the same problem, but I broke other stuff and gave up on it. It sounds like maybe they've fixed it now though, so I might take a look at their new implementation and see if I can figure out a way to port it here Sent from my iPhone
|
Doesn't look like it's fixed in Angular yet :( |
Also seeing this issue. Also can report the workaround helps. For anybody who might be using Jade, here's a quick gotcha: |
+1. |
+1 |
This is still tripping people up a year later? |
Well, it only works for me if I inject $state at the run state. |
.run() hack-fix helped us, but "vanilla-angular" support is really needed, so, +1 |
+1 |
I'll look into this when I have time, but for now, there are plenty of equally-problematic issues that don't have simple workarounds, so I can't logically prioritize this. If someone else wants to dig into it and report back (or better yet, open a PR), that'd be great. |
+1 |
same here, but i found a solution as @ilyagelman mentioned:
will fix, but donno why... |
+1 |
I am having a similar problem, but adding .run does not fix it The xxx button at the top should open a sidenav, just like the big button in the body, and next to the xxx button should be a title. Neither of those are working because they are included in an ng-include |
Same here, .run solution doesn't work |
This issue has been automatically marked as stale because it has not had This does not mean that the issue is invalid. Valid issues Thank you for your contributions. |
ng-include a template that has a ui-view in it. When the page loads, ui-router won't run the current state. Navigate to a new url and back and the state will run.
The text was updated successfully, but these errors were encountered: