Is there is any possible way to get the title attribute into header always when the route changed
Example:
when('/newsletter', {
title: 'News Letter',
templateUrl:'app/Views/segment/newsletter.html'
})
When this route comes the view is newsletter and i need to show the title as newsletter in Header Newsletter Tab
You can have a root scope variable named "title" and change it in your controller by doing $rootScope.title = 'new title';
Or better, you can have this done in the resolve
option in router, for more information, please click: $routeProvider
What you should do is to expose $route
service to the view in either main controller (topmost) or in run block (better):
app.run(['$route', '$rootScope', function($route, $rootScope) {
$rootScope.$route = $route;
}]);
Then in any view you can display current title:
<header>
<h1>{{ $route.current.title }}</h1>
</header>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.