Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Initial/Default value in ng-repeat

Open
#185 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, javascript
Domain
frontend

Research direction

The issue is about the filterBy and countBy filters in angular-filter. Look at the filter implementations in the source code to understand how they handle missing values. The user wants a default value (like 0) when the filter finds no matches. Start by examining the test suite for these filters to see current behavior, then modify the filter logic to return a default count. Verify by updating the example in the issue to show the badge as 0 when no 'User 1' values remain.

Written by the indexing model from the issue text.

Description

My code:

User 1 <span 
class="label label-danger label-as-badge" 
data-ng-repeat="(key,value) in url | filterBy:['ddvalue1']:'User 1' | countBy:'ddvalue1'">{{value}}
</span>

Scenario:
I use combination of filterBy and countBy filter to get drop down value. The default drop down value is set to User 1, its changes when the user selects a value from drop-down and later the value can never be User 1 Example (Default value is User 1 drop-down value is hi,hello,hey. Once user selects either of these values the ddvalue1 field gets updated in DB and user can in future only select value available in drop-down)

The purpose of using the filter above is to display a badge. As the user selects the value from drop down the badge value decrease. Example I have 5 drop-down all set to User 1 initially, hence badge value is 5, once a new drop-down value is selected the the badge value decreases to 4.

The problem is when all the value of drop down is changed the filterBy filter can't find User 1 and as such the count value is not updated. So instead of getting 0 nothing gets displayed. Is there a way to set default values ?

I tried my best to explain, i have attached image as well. I have written same filter for another drop-down, the only thing changes is default value to User 2. As u can see in the image the panel should display value of badges as 1 and 0 for user 1 and user 2 respectively, but since it can't find the filter it displays nothing. I tried using tertiary operator while displaying the output but im not sure what should i compare the *value * too {{ value > 0 ? value : 0}}

upload

Dominant language
JavaScript
Stars
2.9k
Forks
319
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from a8m/angular-filter

All issues in a8m/angular-filter

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.