铁路由器无法找到名为的模板...您确定已定义它吗?

时间:2016-02-16 19:19:22

标签: meteor iron-router

我正在尝试在给定页面上呈现模板,但是我收到以下错误:

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 /客户端/ main.html中

<template name="main">
...
  {{> yield}}
...
</template>

的myapp /客户端/ adPage / adPage.html

<template name="adPage">
   {{title}}
...
</template>

的myapp /客户端/ adPage / adPage.js

Template.adPage.onCreated(function() {
  console.log("on created");
});

如果我将adPage模板移动到我的main.html文件,我不再有错误(我可以看到标题)但是没有调用onCreated。

我尝试将所有内容放在同一客户端文件夹中,并将adPage.js重命名为_adPage.js,一切都按预期工作。 所以我怀疑加载顺序有问题,但无法弄清楚...

谢谢!

1 个答案:

答案 0 :(得分:1)

如果您使用的是广告拦截器。尝试禁用它。它可能是因为文件名

相关问题