Using Angular, in my controller I have a function that calculates the amount of filtered items.
So:
$scope.totalConferenciasRestantes = function () {
return $scope.solicitacoes.data.filter(function (solicitacao) {
return solicitacao.conferido == 0;
}).length;
};
In my view, I need to display the value of this function over and over again. But I have to call the function several times is a bad practice, since you can store the value once in a variable and reuse it if need be.
Example:
var x = y();
inserir(x);
alert('o valor de x é ' + x);
In the case of Angular, can you do this in the view?
Example:
<div ng-if='totalConferenciasRestantes() > 0'>
Falta conferir {{ totalConferenciasRestantes() }}!
</div>
In the above case, would I have to call the view totalConferencaisRestantes
only once?