2017-04-22 47 views
0

我有一個表格,我用ng-repeat顯示數據庫中的條目。這些項目是可以每週或每月訂閱的訂閱。該表有3列名稱,每週和每月。當訂閱每週在每週列下的單元格中出現一個勾號,並且如果每月相同。我使用的是NG-如果在TD標籤旁邊似:Angularjs:如何合併ng條件中的2個條件

<td class="td-with-button center valign-top"> 
    <span ng-if="engine.type == 'WeeklyAnalytics'" class="fa fa-check" aria-hidden="true"> 

    </span> 
</td> 
<td class="td-with-button center valign-top"> 
<span ng-if="engine.type == 'MonthlyAnalytics'" class="fa fa-check" aria-hidden="true"> 

</span> 
</td> 

我想達到的是,有這2 TD在一個與納克級的合併,顯示在右邊的刻度柱。如果可能的話,我想這樣做是爲了讓代碼更加乾淨。

整個表格:

<table class="table full-width no-border" ng-if="subscriptionEnginesFromServer.length != 0"> 
        <thead> 
         <tr> 
          <th class="width-240"> 
           Engine name 
          </th> 
          <th class="width-240"> 
           Weekly 
          </th> 
          <th class="width-240"> 
           Monthly 
          </th> 
         </tr> 
        </thead> 
        <tbody ng-show="!loading"> 
         <tr ng-repeat="engine in subscriptionEnginesFromServer | orderBy:'name'"> 
          <td class=""> 
           <!-- clickable-td --> 
           <span class="first-letter-to-upper"> 
            {{engine.name}} 
           </span> 
           <span class="button-icon button--primary button--delete" ng-click="removeEngineFromSubscriptionServer(websites)"> 
            <i class="fa fa-trash-o"></i> 
           </span> 
          </td> 
          <td class="td-with-button center valign-top"> 
           <span ng-if="engine.type == 'WeeklyAnalytics'" class="fa fa-check" aria-hidden="true"> 

           </span> 
          </td> 
          <td class="td-with-button center valign-top"> 
           <span ng-if="engine.type == 'MonthlyAnalytics'" class="fa fa-check" aria-hidden="true"> 

           </span> 
          </td> 
         </tr> 
        </tbody> 
       </table> 

回答

0

喜歡的東西?

<td colspan="2" ng-class="{ 
    'class-weekly': engine.type == 'WeeklyAnalytics, 
    'class-monthly': engine.type == 'MonthlyAnalytics 
}"> 

使用css來適當地定義類的樣式。

+0

看起來不錯,但我有一個問題,在這裏我把這個圖標放在這裏? 類=「發發覈對」 – Jakub

+0

與您目前的做法,把''細胞 –

+0

我在接下來的方式做,但這不是工作,你能解釋一下我做錯了,請裏面 ' ' – Jakub