首页 > 解决方案 > 如何在 ng-repeat angularJs 中仅突出显示表的第一行?

问题描述

所以我想使用 ng-repeat 以不同颜色突出显示表格顶部的行。这是我的代码:

<table class="table table-hover" style="font-size:14px; margin-left: 5px;">
  <thead>
    <tr>
    <th style="text-align: left;"><data-i18n i18n="_m_f_pen_feeding_start_date_">Feeding date</data-i18n></th>
     <th style="text-align: left;"><data-i18n i18n="_m_f_pen_frequency_of_feeding_">Frequency of feeding</data-i18n></th>
      </tr>
       </thead>
         <tbody>
          <tr ng-repeat="freq in vm.details.pen_feeding_scheduler_list | orderBy:'-start_feeding_date'">
           <td style="min-width: 120px; text-align: left;">{{freq.start_feeding_date | date: 'MM/dd/yyyy'}}</td>
            <td style="min-width: 120px; text-align: left;  display: inline-block;white-space: nowrap">
            {{freq.feeding_frequency || ('_label_empty_' | i18n)}}</td>
          </tr>
        </tbody>
     </table>

这就是我的桌子的样子: table。有什么想法吗?提前致谢

标签: angularjs

解决方案


它必须为你工作<tr ng-repeat="data in datas" ng-class="$index===0?'hover':''"> ........(hover是类名)


推荐阅读