I have main.cshtml file It has a head tag which includes css and js references.
I have two directives / templates. I want to have different two title. When page1 opened (has template1) I want page's title to be Page-1. When page2 opened (has template2) I want page's title to be Page-2.
I tried to put head tags to directive but it doesn't read title and icon-for-title.
<div style="height: 100%">
<head>
<title>{{::title}}</title>}}
<link rel="shortcut icon" href="../../../../icons/icon1.ico">
</head>
<div class="..." >
<div class="...">
<div>...............
It doesn't work neither like that or head tag is over the main div.
I tried to do with routing, in route giving title property but in config file rootScope can not be read.
So I tried to run() with module. But it didn't work too.
module.run(function($rootScope){
$rootScope.$on("$routeChangeSuccess", function(currentRoute,
previousRoute){
//Change page title, based on Route information
$rootScope.title = $route.current.title; }) ;});
Can you please help how can I have these two different title and icons. Or if it has to be two different head tag to see them, how can I create these?
I don't have a lot of information to go on for your specific use case, but we set the title programmatically like this:
You could trigger this code on
$stateChangeSuccess
.In this example, you define the title in the state definition and update it when the state changes:
This examples assumes you're using ui-router for routing.