【问题标题】:Bind more controller properties to one attribute using HTMLBars使用 HTMLBars 将更多控制器属性绑定到一个属性
【发布时间】:2015-08-28 21:57:19
【问题描述】:

这是正确的还是有其他解决方案?

<input disabled={{model.isnValid}} disabled={{isSaving}}>

我知道我可以创建新的 CP 并依赖 model.isnValidisSaving,但我想知道是否有其他解决方案。

谢谢你的建议

【问题讨论】:

  • 不,在这里使用计算属性是正确的方法。

标签: ember.js htmlbars


【解决方案1】:

在这里使用计算属性可能是最好的。另一个可能的解决方案是ember-truth-helpers,它允许您编写如下代码:

<input disabled={{or model.isInvalid model.isSaving}}>

我经常使用 ember-truth-helpers,但这看起来很奇怪,我不会推荐它。

【讨论】:

    猜你喜欢
    • 2016-09-12
    • 2015-06-29
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多