nonplus / angular-ui-router-title

AngularJS module for updating browser title/history based on the current ui-router state.
122 stars 30 forks source link

Trigger title change on event #5

Closed jlsalmon closed 2 years ago

jlsalmon commented 9 years ago

Hi,

I'm wondering how I might be able to trigger a change in the title when an event occurs? I.e. something like:

$rootScope.$on('event:languageChanged', function () {
    // somehow use $title here
});

edit: I'm using angular-translate. I tried the following, but it didn't work:

<title ng-bind-template="{{$title | translate}}"></title>

P.S. Great plugin, thanks!

lunks commented 9 years ago

I believe just updating $rootScope.$title might work, but I haven't tried it yet.

xeroxoid commented 9 years ago

For me that only worked if I defered the execution (via lodash/underscore _.defer function) i.e.:

    _.defer(function () {
        $rootScope.$title = 'Photo of ' + user.name;
    });

else something overwrote it to blank...