-
Notifications
You must be signed in to change notification settings - Fork 19
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
Title is not retained in browser history when used with ui-router #7
Comments
Thanks for the note, David. I'm not too familiar with ui-router so I'd love to see some more details about your workaround so I can think about how it might be solved. Would you mind sharing some code here in the comments or in a gist? |
Here is a plunkr with how we use ui-router with angularjs-viewhead. Unfortunately you can't see history or browser title behavior in plunkr. However, the way I solved the issue in my app is like this: Rather than Finally, I added the following event watcher: $rootScope.$on('$locationChangeSuccess', function() {
if ($rootScope.viewTitleStale && $rootScope.viewTitle) {
delete $rootScope.viewTitle;
}
}); The watcher basically waits for the ui-router to do a $location change, and only then do I delete the viewTitle. Though, I noticed when creating the plunkr, that you have made some changes since the release my bower is pulling in (0.0.1). Are you planning on putting out another release with your new changes? However, I tried doing a similar delayed delete myself, and it didn't seem to work, so I am pretty sure the issue is still there. |
Actually, the fix for it is not to clear the EDIT: Actually, when you use master's version (with clearing the title in |
5226892 does not work for me on angular 1.3 and angular-ui-router 0.2.18. For some reason new view is created before "destroy" event of old view, so 'title = undefined' removes just written title and destroy event always removes the viewTitle. I've fixed it by storing the iElement at the start of link function and comparing it with the element in the closure after the timeout in the destroy function. If the elements are identical, that means no other view-title was parsed since this view-title, and so it should be cleared. Otherwise, another view-title is already in charge, and so do nothing. |
With ui-router, i've fixed changing "$destroy" to "$stateChangeSuccess". |
I am using angular-ui/ui-router (https://github.com/angular-ui/ui-router). The 'destroy' action of the directive occurs prior to ui-router registering the name in the history stack. Therefore, you cannot see the titles in this browser history. I have solved the issue in my project via a workaround. However, the workaround it is not as clean or modular as I would prefer, so I am not going to submit a pull request with it. I did, however, think I should report the issue, in case you can come up with a clean way of handling the issue.
The text was updated successfully, but these errors were encountered: