2016-03-01 37 views
2
<table align="center"> 
    <tr> 
     <th>No</th> 
     <th>Movie Title</th> 
    </tr> 
     <tr data-ng-repeat="mov in movie | pagination: curPage * pageSize | limitTo: pageSize | filter:searchText" data-ng-show="showSuccessMessage" data-ng-click="selectMovie($event,mov)" data-ng-class="{'selected':selectedMovie.film_id===mov.film_id}" style="cursor: pointer;"> 
      <td> 

      </td> 
      <td> 
       {{mov.title}} 
      </td> 
     </tr> 
    </table> 

Aboe代碼是正常工作,但我怎麼能算在沒有數量和顯示?AngularJs數計數

結果 enter image description here

+1

你說話'$ index'的?它是'ng-repeat'中定義的變量,它給你循環的實際索引。 –

回答

1

試試這個

<table align="center"> 
     <tr> 
      <th>No</th> 
      <th>Movie Title</th> 
     </tr> 
      <tr data-ng-repeat="mov in movie | pagination: curPage * pageSize | limitTo: pageSize | filter:searchText" data-ng-show="showSuccessMessage" data-ng-click="selectMovie($event,mov)" data-ng-class="{'selected':selectedMovie.film_id===mov.film_id}" style="cursor: pointer;"> 
       <td> 
        {{ $index + 1 }} 
       </td> 
       <td> 
        {{mov.title}} 
       </td> 
      </tr> 
     </table> 
+0

仍然需要解釋,通過這個http://www.w3schools.com/angular/angular_tables.asp – venkat

+0

work..thxx ^^ ... –

1

您可以使用$index來獲取元素的索引在數組中。它開始於0,所以,你可以打印使用$index + 1