Skip to content

Instantly share code, notes, and snippets.

@imjoshholloway
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imjoshholloway/7df1282e2dfe99a186dd to your computer and use it in GitHub Desktop.
Save imjoshholloway/7df1282e2dfe99a186dd to your computer and use it in GitHub Desktop.
(function(angular, undefined) {
'use strict';
angular.module('app', ['title', 'ui.router'])
.config(appConfig);
function appConfig($stateProvider) {
$stateProvider.state('app.dashboard', {
url: '/',
settings: {
pageTitle: 'Dashboard',
}
});
}
})(angular);
(function(angular, undefined) {
'use strict';
angular.module('title')
.controller('TitleController', TitleController);
function TitleController($scope) {
var vm = this;
vm.pageTitle = '';
$scope.$on('$stateChangeSuccess', updatePageTitle);
//////////
function updatePageTitle(event, toState) {
if (toState) {
if (toState.settings && toState.settings.pageTitle.trim() !== '') {
vm.pageTitle = toState.settings.pageTitle.trim() + ' | App';
return true;
}
}
return 'App';
}
}
})(angular);
(function(angular, undefined) {
'use strict';
angular.module('title', []).directive('title', TitleDirective);
function TitleDirective() {
return {
restrict: 'E',
controller: 'TitleController',
scope: {
name: '='
},
controllerAs: 'title',
bindToController: true,
template: '{{title.pageTitle}}'
}
}
})(angular);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment