angular-datatables rendering (repeating) twice

淺唱寂寞╮ 提交于 2019-12-24 04:03:22

问题


I am using angular datatables https://l-lin.github.io/angular-datatables and noticed that the ng-repeat is done twice. I noticed it with the following directive.

<tr ng-repeat="order in vm.orders track by order.id" repeatlogger>

app.directive('repeatlogger', function() {
    return function (scope, element, attrs) {
        console.log(scope.$index);
}

I am using the Angular way, see HTML tab at https://l-lin.github.io/angular-datatables/#/angularWay

<table datatable="ng" class="row-border hover">
    <thead>
        <tr>
            <th>ID</th>
            <th>FirstName</th>
            <th>LastName</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="person in vm.persons  | limitTo: 50" repeatlogger>
            <td>{{ person.ID }}</td>
            <td>{{ person.Firstname }}</td>
            <td>{{ person.Lastname }}</td>
        </tr>
    </tbody>
</table>

Using a ng-repeat on a div shows that it iterates once over the collection.

Which reasons exist, that angular-datatables iterates twice over the collection?

来源:https://stackoverflow.com/questions/39127688/angular-datatables-rendering-repeating-twice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!