我们如何检查值是否相等ember.js http://www.emberjs.com的 If 块助手?
{{#if person=="John"}}
我们如何在车把上执行上述操作?
The {{#if}}
helper 只能测试属性,不能测试任意表达式。因此,在这种情况下,最好的办法是编写一个属性来计算您想要测试的任何条件。
personIsJohn: function() {
return this.get('person') === 'John';
}.property('person')
Then do {{#if personIsJohn}}
.
注意:如果您发现这太有限,您也可以注册自己的更强大if helper https://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)