Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角度排序依据和范围_Angularjs_Angularjs Scope_Angularjs Filter_Angularjs Orderby - Fatal编程技术网

Angularjs 角度排序依据和范围

Angularjs 角度排序依据和范围,angularjs,angularjs-scope,angularjs-filter,angularjs-orderby,Angularjs,Angularjs Scope,Angularjs Filter,Angularjs Orderby,我想知道当数据分布在多个表中时,如何正确地对表数据进行排序。我有一些基于应用所属国家的表中显示的应用数据,即每个国家都有自己的应用数据表。我可以使用orderBy通过单击表标题(应用程序属性)对表数据进行排序,但单击其中一个国家/地区表的标题会对所有国家/地区表进行排序。我想知道如何隔离范围,以便单击一个国家的应用程序数据表的表标题只更改其应用程序数据的顺序,而不更改其他国家的应用程序数据表。我尝试将countryId属性添加到应用程序数据中,然后根据当前单击的country表进行过滤,但这只会

我想知道当数据分布在多个表中时,如何正确地对表数据进行排序。我有一些基于应用所属国家的表中显示的应用数据,即每个国家都有自己的应用数据表。我可以使用orderBy通过单击表标题(应用程序属性)对表数据进行排序,但单击其中一个国家/地区表的标题会对所有国家/地区表进行排序。我想知道如何隔离范围,以便单击一个国家的应用程序数据表的表标题只更改其应用程序数据的顺序,而不更改其他国家的应用程序数据表。我尝试将countryId属性添加到应用程序数据中,然后根据当前单击的country表进行过滤,但这只会导致其他country表为空。隔离orderBy范围的正确方法是什么

<div class="table-responsive" ng-repeat="countryReleases in regionRelease.countryReleases">
    <h5><strong>{{ countryReleases.countryName }}</strong></h5>
    <table id="app" class="table table-striped table-bordered table-condensed">
        <thead>
            <tr>                    
                <th ng-click="vm.sortCountry = countryReleases.countryId; vm.sortName = 'application.name'; vm.sortReverse = !vm.sortReverse">
                    <span>App Name</span>
                    <span ng-show="vm.sortName == 'application.name' && !vm.sortReverse" class="pull-right fa fa-caret-up"></span>
                    <span ng-show="vm.sortName == 'application.name' && vm.sortReverse" class="pull-right fa fa-caret-down"></span>
                </th>
                <th>App Prop 2</th>
                ...
            </tr>
        </thead>
        <tbody>
            <tr ng-repeat="appReleases in countryReleases.appReleases | filter:vm.sortCountry | orderBy:vm.sortName:vm.sortReverse">
                <td>
                    <img class="thumbnail" ng-src="{{ appReleases.application.icon }}">
                    ... 

{{countryReleases.countryName}
应用程序名称
App道具2
...
... 
//编辑: 通过将当前迭代的范围传递给控制器中的orderBy筛选器修复:

<th ng-click="vm.sortName = 'application.name'; vm.sortReverse = !vm.sortReverse; vm.orderByAppCountry(this, vm.sortName, vm.sortReverse)">
...

<tr ng-repeat="appReleases in countryReleases.appReleases">
...

  function orderByAppCountry(scope, predicate, reverse) {
    scope.countryReleases.appReleases = $filter('orderBy')(scope.countryReleases.appReleases, predicate, reverse);
  }

...
...
函数orderByAppCountry(作用域、谓词、反向){
scope.countryReleases.appReleases=$filter('orderBy')(scope.countryReleases.appReleases,谓词,反向);
}

通过将orderBy筛选器添加到控制器并通过单击国家/地区表进行调用来修复,请参见上面的编辑。

尝试使用数组更新orderBy,但仍然无效
对特定于范围迭代的属性(而不是每个人共享的属性)执行内部
orderBy
。例如,第一次重复是items|orderBy:sharedProperty中的
项,第二次重复是item.subs中的
子项| orderBy:item.order