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

Default $title value #2

Closed dmarcelino closed 9 years ago

dmarcelino commented 9 years ago

I was wondering, if one has lots of routes on their app and doesn't want to set $title on every state, is there a way to set a default $title?

The current issue I'm facing is that if a user goes from a state with $title defined to a state without $title, $title will have the value of the last state. Not a big issue, but could make life easier.

nonplus commented 9 years ago

That's a good point. I'll probably change the behavior s.t. if you go to a state that doesn't resolve a $title (nor do any of its parent states), the $rootScope.$title will be set to undefined.

That way, in you template you would be able to do something like this:

<title ng-bind="$title || 'Default Title'">Default Title</title>
dmarcelino commented 9 years ago

I like that! :+1:

dmarcelino commented 9 years ago

Thanks!

alpha-mouse commented 9 years ago

Sorry, am I missing something, or you've undone your change in the next commit "[Prerelease] Bumped version number" [https://github.com/nonplus/angular-ui-router-title/commit/d4fda7fa06b7c1bac56f96881aeafd5f19e614c6]?