在Angularjs中使用jQuery tableSorter插件

Aki*_*Aki 9 tablesorter angularjs

我正在尝试使用与Angular一起工作的JQuery tablesorter插件.目前,如果单击任何列以对表格的整个宽度和结构进行排序,则会创建具有ng-repeat表达式的新行.

$(document).ready(function() {
    $("#check").tablesorter();
});
Run Code Online (Sandbox Code Playgroud)

 

<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>
Run Code Online (Sandbox Code Playgroud)

iwe*_*ein 5

你这样做是错的.

如果要使用AngularJS对表中的行进行排序,则应使用orderBy过滤器.没有必要包含另一个框架.一旦实现了这一飞跃,您就可以在线(或在SO上)找到大量样本.

例如,请看这个小提琴:http://jsfiddle.net/uRPSL/1/