AngularJS module for updating browser title/history based on the current ui-router state.
Using ui-router states with
url configurations enables browser history support and bookmarking of application state.
It is important that the title in the browser history/bookmark represent the application state so that the user can tell
where she's navigating to.
The module provides a
$title variable on the
$rootScope that is populated based on the
$title value resolved
$state.$current (or one of its parent states). If the current state doesn't resolve a
$rootScope.$title will be
The module also provides a
$breadcrumbs array that is populated based on the
$state.$current and its parent states.
The module sets the
document.title to the value of the
$title variable or, if configured, to the value returned by a
The browser sets bookmark and browser history text based on the
Installing the Module
Installation can be done through bower:
bower install angular-ui-router-title
In your page add:
Loading the Module
This module declares itself as
ui.router.title, so it can be declared as a dependency of your application as normal:
var app = angular;
Specifying the $title in the state definition
A state defines its title by declaring a
$title value in its
It's a good idea for the
$title to include information from the current state,
so it may need to inject the
$stateParam or another value that was resolved from them.
Configuring a custom document.title
By default, the module will set the
document.title to the value of
$rootScope.$title. A common convention is to include
the application name in the document.title. Customization of the
document.title can be achieved via the
Using the $title in a header
$title property contains the resolve title and cen be used, for example, to set the contents of an
Using the $breadcrumbs
$breadcrumbs array contains objects, one for each state that resolves a
$title value. Each entry contains:
title: $title value of this state
state: name of the state
stateParams: $stateParams of the state.
Copyright & License
Copyright 2015 Stepan Riha. All Rights Reserved.
This may be redistributed under the MIT licence. For the full license terms, see the LICENSE file which should be alongside this readme.