Initial/Default value in ng-repeat
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}}
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from a8m/angular-filter
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
a8m/angular-filter#267 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
a8m/angular-filter#260 · 1 reaction ·
-
KiB and MiB are wrongly used in place of kB and MBPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
a8m/angular-filter#254 · 2 comments · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
a8m/angular-filter#250 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
a8m/angular-filter#208 · 1 comment · 1 reaction ·
All issues in a8m/angular-filter
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
developmentseed/deck.gl-raster#693 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
dependencies security
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
dev experience
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cuttle-cards/cuttle#1413 ·
Maintainers usually reply within 1 day
-
macOS
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
beyondcode/herd-community#1761 ·