Skip to content

Commit

Permalink
fix(layout): fixed routes and site title
Browse files Browse the repository at this point in the history
- title now works when the current route does not specify a title
- 404 page has a title
  • Loading branch information
atruskie committed Mar 21, 2016
1 parent 5502809 commit fa31f00
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,24 @@ angular.module("baw",
}).

// missing route page
when("/", {templateUrl: paths.site.files.home, controller: "HomeCtrl"}).
when("/404", {templateUrl: paths.site.files.error404, controller: "ErrorCtrl"}).
when("/404?path=:errorPath", {templateUrl: paths.site.files.error404, controller: "ErrorCtrl"}).
when("/", {
templateUrl: paths.site.files.home,
controller: "HomeCtrl",
title: "Home",
fullWidth: false
}).
when("/404", {
templateUrl: paths.site.files.error404,
controller: "ErrorController",
title: "Not found",
fullWidth: false
}).
when("/404?path=:errorPath", {
templateUrl: paths.site.files.error404,
controller: "ErrorController",
title: "Not found",
fullWidth: false
}).
otherwise({
redirectTo: function (params, location, search) {
return "/404?path=" + location;
Expand Down Expand Up @@ -408,7 +423,9 @@ angular.module("baw",

// https://docs.angularjs.org/api/ngRoute/service/$route
$rootScope.$on("$routeChangeSuccess", function (event, current, previous, rejection) {
document.title = appEnvironment.brand.title + " | " + $route.current.title;

let title = $route.current && ( "|" + $route.current.title) || "";
document.title = appEnvironment.brand.title + title;
$rootScope.fullWidth = $route.current.$$route.fullWidth;
});

Expand Down

0 comments on commit fa31f00

Please sign in to comment.