AngularJS - 使用filter和groupBy后计算结果

时间:2016-07-08 11:57:48

标签: javascript angularjs angular-filters

我正在使用角度angular-filter

过滤和分组正在运行。但我还想检查过滤后的列表是否为空,类似于这个问题: AngularJS - placeholder for empty result from filter

在下面的示例中,我使用overflow: auto通过player in filteredPlayers = (players | filter:search)

访问计数

如何为示例中的分组列表执行类似操作?

代码:



filteredPlayers.length

var app = angular.module('myApp', ['angular.filter']);
app.controller('myCtrl', ['$scope', function($scope) {
  $scope.players = [
  {name: 'Gene', team: 'alpha'},
  {name: 'George', team: 'beta'},
  {name: 'Steve', team: 'gamma'},
  {name: 'Paula', team: 'beta'},
  {name: 'Scruath', team: 'gamma'}
];
}]);




1 个答案:

答案 0 :(得分:0)

你可以做类似的事情:

.topmenu {
    background: #6b00f3 linear-gradient(180deg, #7f0000, #6b0103) repeat scroll 0 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 48px;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
 }
.topmenu .container {
    height: 100%;
}
.topmenu .container .links {
    height: 100%;
}
.topmenu .container .links .link {
    box-sizing: border-box;
    height: 100%;
    text-decoration: none;
    padding: 0 10px;
    color: #fff;
}
.topmenu .container .links .link:not(:last-child) {
    border: 1px solid #630000;
}