简体   繁体   English

Ember.js / Handlebars.js将条件类属性绑定到{{#link-to}}帮助器

[英]Ember.js/Handlebars.js bind conditional class property to {{#link-to}} helper

I am trying to add a class to the link attribute but the class name is conditional. 我试图在link属性中添加一个类,但类名是有条件的。

{{#link-to "role" this classNames="isLoading:is-loading" tag="tr" }}
   <td {{ bind-attr class="isLoading:is-loading"}}>{{ name }}</td>
   <td>{{ role }}: {{ isLoading }}</td>
   <td>EDIT</td>
{{/link-to}}

So just like this. 就像这样。 But somehow it doesn't work. 但不知怎的,它不起作用。

Is there another way to do this? 还有另一种方法吗?

Just use classBinding instead of classNames : 只需使用classBinding而不是classNames

{{#link-to "role" this classBinding="isLoading:is-loading" tag="tr" }}
   <td {{ bind-attr class="isLoading:is-loading"}}>{{ name }}</td>
   <td>{{ role }}: {{ isLoading }}</td>
   <td>EDIT</td>
{{/link-to}}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM