Emidomh Emidomh - 5 months ago 7
AngularJS Question

Using angular, Is it possible somehow to display a value with a filter directly to html code?

Usualy, you are using filter directly in your html code like this :

<div ng-repeat="product in products | filter:{ category : 'car' }">


But in my case I need to use filter to display a value. Something like this :

<p> {{products.length | filter:{category : 'car'} }} Car Product(s) found.</p>


In order to get as output :

8 Car Product(s) found.
(example)

NOTE :

I know how to do it using javascript but this is not what I'm looking for. I want to know if it's possible to do it directly in my html code.

Answer

You can use :

<div ng-repeat="product in filter = ( products | filter:{ category : 'car' })">

And to display the amount just :

{{filter.lentgh}}