I\'m using Vraptor + Angular, and the question is simple. I hide some rows in my table with ng-show, but I want to take the count/length of the actual lines shown.
E
Here is the thing, on one hand you can check DOM and see how many visible rows you have, that will answer your question, but that is really bad solution, that will make performance of your angular app worse and not really angular-ish way to do things.
Another option you have is to create your own filter and use that, in this case you will be able to tell how many items you have within the filter.
Third option which is the best in my opinion is to create another scope variable and fill it in only with filtered items, of course you will need to maintain it in sync with your main list and you can do it using $watch
and $watchCollection
methods of your scope
....
$scope.$data = [ ...]
function ativoOrPerfil(item) {
return item.ativo == filtroAtivo && (filtroPerfil == null || item.perfil == filtroPerfil )
}
function updateFiltered() {
$scope.$dataFiltered = $scope.$data.filter(ativoOrPerfil)
}
$scope.$watch('filtroAtivo', updateFiltered)
$scope.$watch('filtroPerfil', updateFiltered)
Although keep in mind that since you are using strict filter and then your own filter, you will need to tweak updateFiltered to include all 3 conditions you have - filter, ativo and peril