【问题标题】:dart angular components OptionGroup:LabelFunction飞镖角度组件 OptionGroup:LabelFunction
【发布时间】:2017-11-26 10:12:36
【问题描述】:

我正在使用新的材质树并希望将一系列自定义对象作为 OptionGroup 传递,这些对象包含我需要使用 LabelFunction 增强的标签属性,但是,这个特定的 typedef 不接受任何值,并且只是期望输出一个字符串,我猜,我需要一个示例,或者可能需要一个关于我的用法的完整性检查。 给定这个简单的类:

class pulsar {
  String label = '';
  String id = '';

  pulsar();
}

我想创建:

final SelectionOptions pulsars = new SelectionOptions([
    new OptionGroup.withLabelFunction(
        [pulsar1, pulsar2, pulsar3],
        (T) => labeler(T)
]);
// This is the problem, since the typedef String LabelFunction()
// Does not accept parameters.
// I will want this to work...
String labeler(pulsar p) => "${p.id} : ${p.label}";

我想,我想知道我是否错过了这个 LabelFunction..

【问题讨论】:

  • 嗨,我看到你went another way(使用 ItemRenderer)。这会使这个问题完全过时吗?还是您仍然觉得其他人可能需要 LabelFunction?
  • 好吧,我担心这个问题可能来自我自己对 Angular 和新材料树的无知。但是,我想知道这是否有可能……我的意思是,我可以看到有人如何看待“withLabelFunction”并假设“啊哈!,我可以在这里传递我的本地化/正则表达式/字符串模板/等!”并且对如何应用它感到困惑。

标签: angular dart angular-components


【解决方案1】:

没关系,我选择了 ItemRenderer。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-26
    • 2014-09-11
    • 1970-01-01
    相关资源
    最近更新 更多