4

HI我在Chrome和浏览器的数据排序中得到了不同的结果。 Firefox显示正确的一个。Angularjs:在Chrome浏览器和Firefox浏览器中排序显示不同的结果

HTML:

<table class="datatable"> 
       <thead> 
       <tr> 
        <th width="5%" class="Rank">Rank&nbsp;<a ng-click="sort_by('Rank')"><i class="icon-sort" ng-show="pagedItems[currentPage].length > 1"></i></a></th> 
        <th width="10%" class="Interviews">Interviews&nbsp;<a ng-click="sort_by('Interviews')"><i class="icon-sort" ng-show="pagedItems[currentPage].length > 1"></i></a></th> 
        <th width="25%" class="Dealership">Dealership&nbsp;<a ng-click="sort_by('Dealership')"><i class="icon-sort" ng-show="pagedItems[currentPage].length > 1"></i></a></th> 
        <th width="15%" class="Satisfaction">Overall Satisfaction&nbsp;<a ng-click="sort_by('Satisfaction')"><i class="icon-sort" ng-show="pagedItems[currentPage].length > 1"></i></a></th> 
        <th width="15%" class="Loyalty">Loyalty&nbsp;<a ng-click="sort_by('Loyalty')"><i class="icon-sort" ng-show="pagedItems[currentPage].length > 1"></i></a></th> 
       </tr> 
       </thead> 
       <tbody> 
       <tr ng-repeat="item in pagedItems[currentPage] | orderBy:sortingOrder:reverse"> 
        <td>{{item.Rank}} - {{item.$$hashKey}}</td> 
        <td>{{item.Interviews}}</td> 
        <td>{{item.Dealership}}</td> 
        <td>{{item.Satisfaction | number:1}}</td> 
        <td>{{item.Loyalty}}</td> 
       </tr> 
      </tbody> 

我初步排序,以秩:

角控制器代码:

$scope.sortingOrder = sortingOrder; 
$scope.reverse = false; 

结果在Firefox中:排名列显示等级与Hashkey值

Fire Fox Result

Chrome的结果:排名列显示了Hashkey值

Chrom Result

在这里,我以秩排序排名。具有相同等级的数据按其$$ $$ hashkey进行排序。 Firefox提供$$ hashkey以获取数据。作为Chrome的第二个记录在给予散列键时最后持续。

我无法理解为什么会发生这种情况。有什么办法可以避免。

在此先感谢。

回答

2

我在Google Chrome中遇到同样的问题。 补救措施是在页面加载时设置初始排序字段。

我没有做,以前:

$scope.items = {[$data]}  



     $scope.mySortFunction = function(item) { 
      if(isNaN(item[$scope.sortExpression])) 
       return item[$scope.sortExpression]; 
      return parseInt(item[$scope.sortExpression]); 
     } 

我改变了上面这样:

$scope.items = {[$data]}  

     //we want the 1st load to be sorted by sort_code 
     $scope.sortExpression = 'sort_code'; 

     $scope.mySortFunction = function(item) { 
      if(isNaN(item[$scope.sortExpression])) 
       return item[$scope.sortExpression]; 
      return parseInt(item[$scope.sortExpression]); 
     } 
相关问题