将 jQuery tableSorter 插件与 Angularjs 结合使用



我正在尝试使用与Angular一起使用的JQuery表排序器插件。目前,如果您单击任何列进行排序,则表格的整个宽度和结构会发生变化,并创建一个带有 ng-repeat 表达式的新行。

$(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>

你做错了。

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

例如,请参阅此小提琴:http://jsfiddle.net/uRPSL/1/

幸运的是,

有一个名为ng-table的Angular Module。