Meteor 流星通过可变,铁路线
我刚开始,我用铁路由器来操纵路线。。 因此,我想向模板传递一个变量:Meteor 流星通过可变,铁路线,meteor,iron-router,Meteor,Iron Router,我刚开始,我用铁路由器来操纵路线。。 因此,我想向模板传递一个变量: Router.route('/foo', function(){ this.render('foo', {name: 'Stack'}); }); 如何在模板foo中显示变量name: <template name="foo"> <h2>Hi bro, how i can show the variable name here ?? </h2> </template>
Router.route('/foo', function(){
this.render('foo', {name: 'Stack'});
});
如何在模板foo中显示变量name
:
<template name="foo">
<h2>Hi bro, how i can show the variable name here ?? </h2>
</template>
layout.html:
<template name="layout">
{{> yield}}
</template>
{{>产量}
任何解决方案请:)在您的路线中:
Router.route('/foo', function(){
this.render('foo', {data: {name: 'Stack'}});
});
在模板中
<template name="foo">
<h2>Hi bro, how i can show the variable name here ?? </h2>
<p>Like this --> {{name}}</p>
</template>
有关更多信息,请参见。您可以定义模板帮助器以获取路由器名称:
Template.foo.helpers({
name: Router.current().route.getName()
});
然后在模板中显示为:
{{name}}
Template.foo.helpers({
name: Router.current().route.getName()
});
{{name}}