Giter Site home page Giter Site logo

Comments (5)

apparentlymart avatar apparentlymart commented on August 16, 2024

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.

davideanderson avatar davideanderson commented on August 16, 2024

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.

fracz avatar fracz commented on August 16, 2024

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.

pelepelin avatar pelepelin commented on August 16, 2024

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.

luishmcmoreno avatar luishmcmoreno commented on August 16, 2024

With ui-router, i've fixed changing "$destroy" to "$stateChangeSuccess".

from angularjs-viewhead.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.