我正在为我的Ember项目使用以下库:
DEBUG: -------------------------------
DEBUG: Ember.VERSION : 1.0.0
DEBUG: Handlebars.VERSION : 1.0.0
DEBUG: jQuery.VERSION : 2.0.2
DEBUG: -------------------------------
在为我的应用程序拼凑Handlebars模板时,我发现了一些奇怪的(?)行为,Ember因为我想在{{with}}块助手中创建一个 CSS 类绑定。似乎不知何故,这并没有按预期工作:
...
{{#with controller.currentData}}
<div class="mydata-container" {{bind-attr class="this.hasError:error:ok"}}>
{{this.foo}} - {{this.bar}}
</div>
{{/with}}
...
将<div/>始终显示类似data-bindattr-666=666(数量当然在增加)但课程永远不会被“注入”。(如果我省略this关键字也没有区别,它也适用于显示数据)。如果我尝试{{log this.hasError}}得到等待的结果(true:false)。
{{with}}如果我在没有助手的情况下编写模板,如下所示:
...
<div class="mydata-container" {{bind-attr class="controller.currentData.hasError:error:ok"}}>
{{controller.currentData.foo}} - {{controller.currentData.bar}}
</div>
...
它按预期工作。
这是一个已知问题/错误Ember吗?