【问题标题】:Meteor - Filter a Collection at template level subscription?Meteor - 在模板级别订阅过滤集合?
【发布时间】:2016-04-20 23:43:46
【问题描述】:

目前我有一个订阅集合的模板:

Template.Actividades.onCreated(function(){
    var self = this;
    self.autorun(function(){
        self.subscribe("recursos");
    });
});

Template.Actividades.helpers({
    recursos: function() {
        return Recursos.find({clase: "Actividades"});
    }
});

不幸的是,当我使用条件执行 find({}) 时,我仍然可以显示集合中的所有项目,而不仅仅是将“Actividades”作为“分类”的项目。

下面是与这部分相关的 Collection Schema:

RecursosSchema = new SimpleSchema({
  clase: {
    type: String,
    label: "Clase",
    allowedValues: ["Actividades", "Colegios", "Jardines"],
    autoform: {
      afFieldInput: {
        firstOption: "(Selecciona una clase)"
      }
    }
  },

问题是我在 find({}) 条件下做错了什么?

感谢您的帮助。

【问题讨论】:

  • 您确定这是退回所有商品吗?转到您的浏览器控制台并运行这个确切的查询Recursos.find({clase: "Actividades"}).fetch(),看看你得到了什么。

标签: javascript meteor meteor-blaze


【解决方案1】:

问题已修复,错误代码在迭代模板级别。

感谢您的帮助。

【讨论】:

    猜你喜欢
    • 2016-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-27
    相关资源
    最近更新 更多