【发布时间】:2014-02-17 04:00:39
【问题描述】:
在我的 MEAN 堆栈应用程序中,我正在尝试根据页面上加载的内容更改页面标题(设置为翡翠)。目前,它为 SPA 中的每个页面显示一个通用页面标题。
为我正在做的索引设置页面标题
index.js
res.render('index', {
title: 'Generic Page Title'
});
然后当我返回内容(不同的角度路线/页面)时,我想更新这个标题
offers.js
Offer.find(searchObject).sort('-pricing.pctSavings').exec(function(err, offers){
if (err) {
res.render('error', {
status: 500
});
} else {
//update title?
res.jsonp(offers);
}
});
头玉
title= appName+' - '+title
我不确定如何更改此设置,因为优惠在页面内以 json 格式返回。我尝试将标题添加到响应中(res.locals.title = 'Test unique title'),但它不起作用。
有什么想法吗?
谢谢!
添加更多信息:
我可以在jade模板中包含一些html如下:
头玉
head
div(data-ng-include="'views/dynamic_title.html'")
meta(charset='utf-8')
meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1')
meta(name='viewport', content='width=device-width,initial-scale=1,user-scalable=no')
views/dynamic_title.html
<div data-ng-controller="OffersController">
<title> Test </title> //works
<title> {{test}} </title> //test set in offers controller - doesn't work
<title> {{ Page.title() }}</title> //Page injected into offers controller - doesn't work
</div>
优惠控制器直到稍后才会加载...
谢谢。
【问题讨论】:
标签: node.js angularjs express pug mean-stack