[英]How Do I Render Table With Meteor Spacebars Template and Row Number For Each Row?
[英]How Do I Set Meteor Template Title On Render?
我有一个动态的代码行:
<label>{{title}}</label>
//template name="header"
我正在使用iron:router,该应用程序现在非常简单:
Router.configure({
layoutTemplate: 'ApplicationLayout'
})
Router.route('/', {
template: "home"
})
Router.route('/scientific', {
template: "scientific"
})
我想要一种不依赖Session
作为动态呈现{{title}}
的方法的解决方案。
理想情况下,我想在路由器代码中的某个位置定义该标题,然后让我的标头自动将其选中。 我不想在我的Template.rendered回调中做很多Session.set / get(我似乎在使用Semantic-UI复选框时遇到问题)。
你们有优雅,超简单的解决方案吗?
PS:模板“标头”位于ApplicationLayout模板中。 ApplicationLayout在标题下方有一个{{> yield}}
。
一个可行的选择是将您的标题存储在路线选项中,如下所示:
Router.route("/",{
template:"home",
title:"Welcome Home !"
});
Router.route("/scientific",{
template:"scientific",
title:"Scientific stuff"
});
然后,您可以基于(反应性)当前路径控制器在标题模板上定义标题助手。
Template.header.helpers({
title:function(){
return Router.current().route.options.title;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.