流星服务器端路由中断订阅

时间:2016-05-19 08:55:40

标签: javascript mongodb meteor iron-router meteor-blaze

我已经和Template填充了Collection中的一些数据。

从这个模板中,我有一个下载文件的按钮(来自服务器端路由)。 路由到此服务器路由(并下载文件)后,模板不再显示数据。 我猜服务器路由会破坏客户端路由上的订阅,我找不到解决方法...

我正在进行服务器端路由以从服务器下载文件,如:

Router.route('/csv/:csvName', {
       name: 'api',
       where: 'server',
       action: function() {
           var filePath = process.env.PWD + '/.scored-categ-csv/' + this.params.csvName;
           var data = fs.readFileSync(filePath);
           this.response.writeHead(200, {
               'Content-Type': 'text/csv'
           });
           this.response.write(data);
           this.response.end();

       }
    });

此路线是来自模板的调用,如:

<template name="tabularAnalytics">
<div class="row">
    <a href="/csv/{{metadata.csvPath}}" class="button">Export to Csv</a>
</div>

//When I vizualize this template, data is displayed, but after clicking on the "Export to csv" button, data is not here anymore

{{data}}
</template>

从这条路线中接受他的订阅:

Router.route('/analytics/tabular/:provider', {
  name: 'tabularAnalytics',
  template: 'tabularAnalytics',
  subscriptions: function(){
    return Meteor.subscribe("scoredCategLastByProvider", this.params.provider);
  },
  data: function(){
    return ScoredCategories.findOne({});
  },
  action: function(){
    if(this.ready()){
      this.render();
    }
  }
});

有人已经面临这个问题吗?

0 个答案:

没有答案
相关问题