如何根据DIV文本应用ng-class - angularjs

时间:2017-07-28 07:29:26

标签: angularjs

我在表格中有以下ng-repeat;

    <tbody>
        <tr ng-repeat="hour in workhours">
            <td >{{hour}}:00 - {{hour+1}}:00</td>
            <td ng-class="{'full' : }" ng-click="checkSlotAvailability(hour, entry, jobLength, data)" ng-repeat="entry in data.calendar" >
                {{entry.HoursAvailable.includes(hour) ? 'AVAILABLE' : 'FULL'}}
            </td>
        </tr>
    </tbody>

    .full{
        background-color: red;
     }

我希望表格单元格在单元格上有“FULL”文本时显示红色。与'full'ng-class配对的内容是什么?

1 个答案:

答案 0 :(得分:2)

尝试使用否定运算符。仅当.full为false(要显示FULL文本的条件)时,您才希望应用entry.HoursAvailable.includes(hour)

ng-class="{'full' :!entry.HoursAvailable.includes(hour)  }"