问题描述
HI我得到不同的结果在Chrome和数据整理的Firefox浏览器。 Firefox的显示正确的。
HI I am getting different result in chrome and firefox browser of sorting of data. Firefox shows correct one.
HTML
<table class="datatable">
<thead>
<tr>
<th width="5%" class="Rank">Rank <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 <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 <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 <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 <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>
我初步排序,与排名:
I am sorting initially with Rank :
角控制器code:
$scope.sortingOrder = sortingOrder;
$scope.reverse = false;
在Firefox
结果:排名列显示与排名值Hashkey
Result in Firefox : Rank Column shows Rank with Hashkey value
Chrome的结果:排名列显示与排名值Hashkey
Chrome Result : Rank Column shows Rank with Hashkey value
在这里,我与排名排序。与同级别得到的数据的$$ hashkey后排序。火狐给出$$ hashkey为了它得到的数据。其中,作为Chrome的订货量大的第二个记录到最后在给哈希键。
Here I am sorting with Rank. The Data with Same Rank gets sorted after their $$hashkey. Firefox gives $$hashkey in order it gets data. where as Chrome palce the second record to last in giving hash key.
我不能够理解为什么发生这种情况。有没有什么办法可以回避。
I am not able to understand why this is happening. is there any way i can avoid.
先谢谢了。
推荐答案
我在谷歌Chrome同样的问题。
补救的办法是设置在页面加载初始排序字段。
I had the same problem in Google Chrome.The remedy was to set the initial sort field upon page load.
我不这样做,previously:
I was not doing that previously:
$scope.items = {[$data]}
$scope.mySortFunction = function(item) {
if(isNaN(item[$scope.sortExpression]))
return item[$scope.sortExpression];
return parseInt(item[$scope.sortExpression]);
}
我改变了上面这样:
I changed the above to this:
$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]);
}
这篇关于Angularjs:排序显示不同的结果在Chrome和Firefox浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!