Angular ng-repeat过滤结果是否可访问?

时间:2017-01-10 12:44:24

标签: angularjs

我成功使用ng-repeat及其过滤器和orderBy函数

<div ng-repeat="center in centers  | filter: subjectName | orderBy:[\'name\',\'parent']">'

然而,当用户决定打印/下载过滤并按角度排序的“中心”时,打印方法失败,因为它只知道原始未排序的未过滤的数组。有没有办法捕获过滤/ orderBy角度方法产生的对象,所以我可以直接在我的打印方法中使用它?

<div ng-repeat="center in centers  | filter: subjectName | orderBy:[\'name\',\'parent']">'
    '<span>{{center.name}</span>'+
</div>
....
// what I have so far
<li><a ng-click="print(centers)"><span class="glyphicon glyphicon-print"></span> Print All </a></li>
...

// what I would like to have
...
<li><a ng-click="print(filteredOrderedObject)"><span class="glyphicon glyphicon-print"></span> Print All </a></li>
...
// what I have
scope.print = function(ocw) {
   //printing
}

// what I would like to have
scope.print = function(filteredOrderedObject) {
   //printing
}

2 个答案:

答案 0 :(得分:0)

您可以直接在代码中使用<?PHP echo "Firstline"; include('classes/connection.php'); echo "I will run if include but not on Require"; ?> 服务。这样的事情。

$filter

https://docs.angularjs.org/api/ng/filter/filter

答案 1 :(得分:0)

您可以使用$ eval来评估控制器中的表达式。

以下是语法

$scope.centers = $scope.$eval("center in centers  | filter: subjectName | orderBy:[\'name\',\'parent']");