0

I have been trying to get the count of items that have a specific text match for a specific field but I haven't had any luck.

The link below is the closest example I have been able to implement, but all I can get it to return is the total number of entries in the table. Angular Count Filtered Data

When I insert {{data.length}} into the view, it returns the total number of entries. But when I change it to query the sub-field as {{(data|filter:{team:'A'}).length}} or {{(data|filter:{custom_fields.team:'A'}).length}} it returns a 0.

[{
    "id": 1,
    "custom_fields": {
        "team": ["A"]
    }
},{
    "id": 2,
    "custom_fields": {
        "team": ["B"]
    },
},{
    "id": 3,
    "custom_fields": {
        "team": ["A"]
    }
}]

Any thoughts or suggestions?

Community
  • 1
  • 1
TheIntrepidSpiff
  • 189
  • 2
  • 2
  • 15

1 Answers1

2

You can do that by filtering nested objects:

{{(data|filter:{custom_fields: {team: ['A']} }).length}}

Demo.

Walid Ammar
  • 4,038
  • 3
  • 25
  • 48