Initial/Default value in ng-repeat
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- angular, javascript
- 领域
- frontend
调研方向
这个 issue 关于 angular-filter 中的 filterBy 和 countBy 过滤器。查看源代码中的过滤器实现,以了解它们如何处理缺失值。用户希望在过滤器找不到匹配项时有一个默认值(例如 0)。先检查这些过滤器的测试套件以了解当前行为,然后修改过滤器逻辑以返回默认 count。通过更新 issue 中的示例来验证:当不再有 'User 1' 值时,将 badge 显示为 0。
由索引模型根据 Issue 内容生成。
描述
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}}
- 主要语言
- JavaScript
- 星标
- 2.9k
- 派生
- 319
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
a8m/angular-filter 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
a8m/angular-filter#267 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
a8m/angular-filter#260 · 1 个 reaction ·
-
KiB and MiB are wrongly used in place of kB and MB可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
a8m/angular-filter#254 · 2 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 65/100
a8m/angular-filter#250 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
a8m/angular-filter#208 · 1 条评论 · 1 个 reaction ·
查看 a8m/angular-filter 的全部 Issue
相似的 Issue
-
enhancement
难度 1/5 1 小时以内 新手友好度 90/100
-
app bug config windows-os
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
clawsweeper:needs-product-decision clawsweeper:needs-security-review clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:security issue-rating: 🦞 diamond lobster P2
难度 2/5 1-3 小时 新手友好度 68/100
openclaw/openclaw#166870 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
⚠ needs intervention document structure changed
难度 2/5 1-3 小时 新手友好度 72/100
-
[Package] Widget primitives [Type] Enhancement
难度 2/5 1-3 小时 新手友好度 85/100
WordPress/gutenberg#84204 · 1 条评论 ·
维护者通常 1 天内回复