【问题标题】:Get label for AutoForm option value in Meteor Simple Schema在 Meteor Simple Schema 中获取 AutoForm 选项值的标签
【发布时间】:2015-12-31 10:21:00
【问题描述】:

在 Meteor 模板中 {{parameter}} 返回此架构的选项值:

new SimpleSchema({
  parameter: {
    type: String,
    allowedValues: ['value_1', 'value_2'],
    autoform: {
      options: [
        {label: "label_1", value: 'value_1'},
        {label: "label_2", value: 'value_2'}
      ]
    }
  },
});

如何在我的模板中获得label 而不是value

【问题讨论】:

    标签: meteor meteor-autoform simple-schema


    【解决方案1】:
    Template.yourTemplate.helpers({
      label: function (value) {
        return _.findWhere(YourSchema.schema('parameter').autoform.options, { value: value }).label;
      }
    });
    

    【讨论】:

    • 非常感谢,这正是我需要的。
    猜你喜欢
    • 1970-01-01
    • 2014-07-21
    • 2014-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-09
    • 2016-03-23
    相关资源
    最近更新 更多