Comments (5)
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?
from angularjs-viewhead.
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.
http://plnkr.co/edit/alLL86MllUecexa6iYWw
However, the way I solved the issue in my app is like this:
Rather than delete $rootScope.viewTitle
in the title, I instead set the value $rootScope.viewTitleStale = true;
I also added $rootScope.viewTitleStale = false;
where the viewTitle is assigned.
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.
from angularjs-viewhead.
Actually, the fix for it is not to clear the $rootScope.viewTitle
on scope's $destroy
event. A one little drawback is that title won't change if your new view does not declare one. But if you have <view-title>
on every view, it should not be an issue.
EDIT: Actually, when you use master's version (with clearing the title in $timeout
), angular-ui-router also works as expected.
from angularjs-viewhead.
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.
from angularjs-viewhead.
With ui-router, i've fixed changing "$destroy" to "$stateChangeSuccess".
from angularjs-viewhead.
Related Issues (11)
- Is this still maintained or ... HOT 2
- minified
- Can I make a pull request? HOT 2
- trying to using with templating
- remove listener on destroy
- Can I use this to dynamically set og metatags without a pre-render server? HOT 1
- Using <title view-head> rather than <view-head>
- Dynamic content from scope not loading for meta tags HOT 3
- Problem when used with ui-router's ui-sref
- Not installable through NPM
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angularjs-viewhead.