-
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
Single URL app - $apply() adds "/#/" to the URL #155
Comments
I'd say that's the core AngularJS $location service doing that. If you want to avoid that, try removing the URL from your root state as well and transition into it via $state.transitionTo('yourrootstate', {}) from a module.run() callback. |
Thank you for your fast reply, great! :) Just tried it and removed the url:"", unfortunately the "/#/" is still there. Is it possible to disable the $location service? |
You might try adding |
Thank you, but unfortunately doesn't work. |
The problem occurs in angular 1.1.5, but not in 1.0.7. |
1.1.5 does introduce some changes to the $location service. That's why I thought base href would help. I thought it did for me. However, I was switching between html5 and hashbang modes. It turns out that when I'm in hashbang mode, my home URL is http://localhost/#/ even with base href='/'. This is actually ok with me, since in hashbang mode, all the other URLs have #/ in them, too, but I understand that you don't want that behavior. I mis-linked the base href issue before. It's actually: angular/angular.js#2799 . It's not clearly related, however there are some 1.1.5 commits linked in that issue which might be in the neighborhood of the problem. You might want to test with 1.1.4 to narrow it down. |
Same behavior with 1.1.4 in hashbang mode. Back with 1.1.5 i turned html5Mode on and voila it's gone. BUT what's about IE<=9 or other incompatible browsers? That's why i avoided html5 mode at the beginning. Is there something wrong with 1.1.4/1.1.5 and their $location services? |
html5 mode doesn't use hashbangs, so it's good that it's not there in that |
yes, but i need a solution for none html5 browsers too I try to illustrate my problem again home view = "localhost:8888" home view is the only gateway to all other views The browsers history function now detects that URL change and shows a back button. But i don't want that back button |
I'm confused -- three questions:
|
BTW: I now think I recall seeing the issue in my #2 question above when I |
Sorry for the confusion. 1.) no |
i have absolutely no urls defined in my states and don't use routeProvider it should always be: localhost:8888 for each state/view |
Do you use $urlRouterProvider? I managed to get these trailing hashbang and slash only when I set What's interesting, a similar issue can be observed on ui-router sample. Going to http://localhost:8000/sample/ I'm being redirected to http://localhost:8000/sample/#/. But, if I remove |
No i don't use $urlRouterProvider or do you mean $routeProvider? When i set $routeProvider.otherwise({redirectTo: "/"}) or $routeProvider.otherwise("/") in hashbang mode i get 'localhost:8888/#/' through the entire app. But now i get errors when additional templates are loaded via ngInclude (seems to be path errors). But the real problem for me is, that i don't want and use $routeProvider. |
@bbshopadmin No, it's a different thing. Hmm, I have no other ideas. Maybe you could reproduce this behaviour using Plunker? This would help to narrow down the problem. |
Good idea. Can you observe the apps URL changes in plunker? i only see something like http://plnkr.co/edit/123abc?p=preview. |
Your link doesn't work. You can always transform the edit URL to the URL with a preview without the iframe. For example, from http://plnkr.co/edit/vDURUN to http://run.plnkr.co/plunks/vDURUN/. But it doesn't matter what the tool you use, I just would like to see the code which clearly demonstrates the problem. |
Sorry, i meant the plunker url only as example to a plunker. A plunker only makes sense if we can observe the url of the app. I don't kown whether this is possible since this issue is url related. |
Hit the blue full screen button in the upper right of the preview. Then you'll see the url. |
I don't know why my plunker doesn't work: http://plnkr.co/edit/YRx1LLa8BOPP357VyrE5?p=preview. It's ui-router quick start example based. |
Now it runs: http://plnkr.co/edit/YRx1LLa8BOPP357VyrE5?p=preview But i also can't see an URL change when i do a redirect via $routeProvider.otherwise({redirectTo: '/test'}). |
Sorry, i found an obsolete event listener which called $location.path(next_path) with next_path="" that added the "/#/". But only since angular 1.1.4. When i look at the changelog i can't see why since 1.1.4. Sorry again! |
Hi,
i use UI-Router for a app without any URLs/deeplinking, only pure states. It' works fine till i call $apply() to update scope vars inside a controller. Somehow $apply adds "/#/" to the URL. Views without $apply() working fine.
Currently it behaves like that:
state A = "localhost:8888"
state B = "localhost:8888/#/" <- $apply() in the controller
The sole exception i declared a URL is in my root state
url: "",
Any ideas?
Edit: above with angular 1.1.5 (hashbang mode)
if i turn on html5mode "/#/" won't be added anymore.. but i don't want html5 mode due to compatibility issues
The text was updated successfully, but these errors were encountered: