2017-07-28 24 views
1

我在表中有以下的ng-repeat;如何基於DIV文本應用ng-class - angularjs

<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'文本的位置顯示爲紅色。 ng-class中的'full'是什麼配對?

回答

2

嘗試使用否定運算符。僅當entry.HoursAvailable.includes(hour)爲假時纔會應用.full類別(滿足出現的條件)

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