2017-07-28 63 views
0

我有以下ng-repeat調用,它在前端顯示平坦的'AVAILABLE'或'FULL'。需要通過修改html來從$scope中讀取更具動態性。

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

在地方的 '可用',我想讀$scope.data.response在controller.js響應

+0

如何'$ scope.data.response'外觀喜歡? –

+0

它只是一個字符串,例如'$ scope.data.response ='AVAILABLE''。基本上將邏輯移至控制器。 –

回答

1

你可以做到這一點

<span ng-if="entry.HoursAvailable.includes(hour)"> 
    {{ data.response }} 
</span> 
<span ng-if="!entry.HoursAvailable.includes(hour)"> 
    FULL 
</span> 
+0

現在工作謝謝。點擊時如何限制顯示到單個單元格。現在所有的單元格都會改變文字。 –

+0

在'data.response'中使用數組來存儲行單元格值並在模板中使用'$ index' – jagzviruz