Mayur Randive
Mayur Randive

Reputation: 643

How to handle filter in Angular expression

Please have a look at below code

Json object

namelist = [{name: "Mayur" , checked : true }, { name: "Rayum" , checked : false }]

In HTML i want to show number of items which are checked true , for above Json object count should be 1.

{{namelist.length}} // gives me total count 
//can we do something like below 
{{ namelist.length | filter {checked:true} }} 

which we give me only count of the filtered count.

Upvotes: 0

Views: 61

Answers (2)

E. Abrakov
E. Abrakov

Reputation: 463

Try this: {{ (namelist | filter:{checked:true}).length }}

You can read about filters here

Upvotes: 2

Alexander Kravets
Alexander Kravets

Reputation: 4385

Try this:

{{ (namelist | filter: { checked: true }).length }}

Upvotes: 2

Related Questions