2017-09-02 53 views
0

我不明白为什么这不绑定类,当我选择框,selectedBox有索引与数量,我用函数indexOf(索引)> -1返回true或false值。 有人可以帮助我吗?aureliajs如何绑定类属性

<div class="col" repeat.for="[item] of range(0, 25)"> 
    <label> 
     <input type="checkbox" model.bind="item" checked.bind="selectedNumbers" class="d-none"> 
     <span class="boxList ${selectedNumbers.indexOf(item) ? 'active': ''}">${item | numberFormat}</span> 
    </label> 
</div> 

回答

1

如果我理解正确的话,你要显示24号,并添加classspan点击复选框时:

我创建了一个gist

<div class="col" repeat.for="item of 25"> 
    <label> 
     <input type="checkbox" model.bind="item" checked.bind="selected" class="d-none"> 
     <span class="boxList ${selected ? 'active': ''}">${item}</span> 
    </label> 
</div>