【发布时间】:2018-09-27 13:06:27
【问题描述】:
我有 main.cshtml 文件 它有一个包含 css 和 js 引用的 head 标签。
我有两个指令/模板。 我想有不同的两个标题。当 page1 打开(有 template1)时,我希望页面的标题为 Page-1。 当 page2 打开(有模板 2)时,我希望页面的标题为 Page-2。
我试图将 head 标签放到指令中,但它不读取标题和 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>...............
它既不能这样工作,也不能在主 div 上使用 head 标签。
我尝试使用路由,在路由中给出标题属性但在配置文件中 rootScope 无法读取。
所以我尝试用模块运行()。但这也没有用。
module.run(function($rootScope){
$rootScope.$on("$routeChangeSuccess", function(currentRoute,
previousRoute){
//Change page title, based on Route information
$rootScope.title = $route.current.title; }) ;});
你能帮我如何拥有这两个不同的标题和图标。或者如果必须是两个不同的 head 标签才能看到它们,我该如何创建它们?
【问题讨论】:
标签: angularjs angularjs-directive head ico angularjs-templates