I am using ng-view to include AngularJS partial views, and I want to update the page title and h1 header tags based on the included view. These are out of scope of the parti
When I had to solve this, I couldn't place the ng-app
on the page's html
tag, so I solved it with a service:
angular.module('myapp.common').factory('pageInfo', function ($document) {
// Public API
return {
// Set page tag. Both parameters are optional.
setTitle: function (title, hideTextLogo) {
var defaultTitle = "My App - and my app's cool tagline";
var newTitle = (title ? title : defaultTitle) + (hideTextLogo ? '' : ' - My App')
$document[0].title = newTitle;
}
};
});