2012-11-26 13 views
9

Sto provando a utilizzare il plug-in per il plug-in di JQuery che funziona insieme ad Angular. Attualmente se si fa clic su una colonna per ordinare l'intera larghezza e struttura della tabella, viene creata una nuova riga con le espressioni di ripetizione ng.Utilizzo del plug-in jQuery tableSorter con Angularjs

$(document).ready(function() { 
    $("#check").tablesorter(); 
}); 

 

<table id="check" class="table table-bordered table-striped table-condensed table-hover tablesorter" cellspacing="1"> 
    <thead> 
     <tr>   
      <th class="header">Product Code#</th> 
      <th class="header">Item Description#</th> 
      <th class="header">Unit Cost#</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr ng:repeat="i in itemresponse" > 
      <td><a href="#/ItemSearch/{{i._ItemID}}" >{{i._ItemID}}</a></td> 
      <td>{{i.PrimaryInformation._ShortDescription}}</td> 
      <td>{{i.PrimaryInformation._UnitCost}}</td> 
     </tr> 
    </tbody> 
</table> 
+2

La prima cosa che farei è spostare la chiamata del tablesorter a una direttiva. Puoi cambiare la priorità della tua direttiva per essere chiamata dopo ng: si chiama repeat. Vedi http://youtu.be/iB7hfvqyZpg –

+2

Guarda l'esempio su http://docs.angularjs.org/api/ng.filter:orderBy Creare una tabella ordinabile con AngularJS è possibile senza tablesorter. –

+0

Ti aiuta in qualche modo: http://plnkr.co/edit/VOf0DjZiKA2VxrWUDUgj?p=preview – eugenekgn

risposta

5

Lo stai facendo male.

Se si desidera ordinare le righe in una tabella con AngularJS, è necessario utilizzare il filtro orderBy. Non è necessario includere un altro framework. Una volta fatto questo salto, puoi trovare una pletora di campioni online (o su SO).

Vedi per esempio questo violino: http://jsfiddle.net/uRPSL/1/

2

Per fortuna c'è un modulo angolare chiamato ng-table.

Problemi correlati