Iron router 无法找到名为...的模板。您确定已定义它吗?
Iron router Couldn’t find a template named... Are you sure you defined it?
我正在尝试在给定页面上呈现模板,但出现以下错误:
Couldn't find a template named "adPage" or "adPage". Are you sure you defined it?
myapp/lib/router.js
我是这样定义路线的:
Router.route("/dashboard/adpage/:_id", {
// name:"adPage",
template:"adPage",
data:function(){
return Ads.findOne({_id: this.params._id});
},
onBeforeAction : function()
{
if(Meteor.userId())
{
//user is loggedin continue the route
this.next();
}
else {
console.log("user not loggin, redirect to login page");
this.render('login');
}
},
onAfterAction: function(){
document.title = 'Annonce';
},
waitOn:function(){
return Meteor.subscribe("adDetails",this.params._id);
}
});
myapp/client/main.html
<template name="main">
...
{{> yield}}
...
</template>
myapp/client/adPage/adPage.html
<template name="adPage">
{{title}}
...
</template>
myapp/client/adPage/adPage.js
Template.adPage.onCreated(function() {
console.log("on created");
});
如果我将 adPage 模板移动到我的 main.html 文件,我不再有错误(我可以看到标题)但不会调用 onCreated。
我尝试将所有内容都放在同一个客户端文件夹中,并将 adPage.js 重命名为 _adPage.js,一切都按预期进行。
所以我怀疑加载顺序有问题,但无法弄清楚是什么...
谢谢!
如果您使用广告拦截器。尝试禁用它。可能是因为文件名
我正在尝试在给定页面上呈现模板,但出现以下错误:
Couldn't find a template named "adPage" or "adPage". Are you sure you defined it?
myapp/lib/router.js
我是这样定义路线的:
Router.route("/dashboard/adpage/:_id", {
// name:"adPage",
template:"adPage",
data:function(){
return Ads.findOne({_id: this.params._id});
},
onBeforeAction : function()
{
if(Meteor.userId())
{
//user is loggedin continue the route
this.next();
}
else {
console.log("user not loggin, redirect to login page");
this.render('login');
}
},
onAfterAction: function(){
document.title = 'Annonce';
},
waitOn:function(){
return Meteor.subscribe("adDetails",this.params._id);
}
});
myapp/client/main.html
<template name="main">
...
{{> yield}}
...
</template>
myapp/client/adPage/adPage.html
<template name="adPage">
{{title}}
...
</template>
myapp/client/adPage/adPage.js
Template.adPage.onCreated(function() {
console.log("on created");
});
如果我将 adPage 模板移动到我的 main.html 文件,我不再有错误(我可以看到标题)但不会调用 onCreated。
我尝试将所有内容都放在同一个客户端文件夹中,并将 adPage.js 重命名为 _adPage.js,一切都按预期进行。 所以我怀疑加载顺序有问题,但无法弄清楚是什么...
谢谢!
如果您使用广告拦截器。尝试禁用它。可能是因为文件名