【发布时间】:2014-08-05 09:45:23
【问题描述】:
我找到了车把的比较助手https://gist.github.com/doginthehat/1890659。 我尝试这样使用它:
{{#each item in model.records}}
<div>
{{#compare model.currentUser.id item.poster_id}}
<div class="author current">{{model.currentUser.name}}</div>
{{else}}
<div class="author remote">{{model.remoteUser.name}}</div>
{{/compare}}
<div class="td message-text">
{{item.poster_id}}{{item.text}}
</div>
</div>
{{/each}}
但它不起作用。因为助手不将第二个参数识别为整数值。助手仅获取文本“item.poster_id”。我还尝试使用 this.get(rvalue) 在助手中获得价值。但它仍然没有工作。我阅读了很多关于它的问题,但我找不到解决方案。 请告知如何比较每个块中的值?或者也许我需要使用另一种方法。
【问题讨论】:
标签: javascript ember.js handlebars.js