Checkbox [ngModel] does not reflect model value when updated in (onModelChange)
- 主要语言
- TypeScript
- 星标
- 101k
- 派生
- 27.5k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 288
描述
**I'm submitting a ...** (check one with "x")
```
[x] bug report
[ ] feature request
[ ] support request
```
**Current behavior**
``````
Behaves exactly like:
``````
The checkbox only reflects the model value when it is first rendered, but then becomes functionally equivalent to a checkbox without a binding. Manually detecting changes or using `setTimeout` inside `(ngModelChange)` does not work around this issue. The same workarounds _do_ work when used with `(click)`, but voids the use of `[ngModel]`.
**Expected behavior**
The logic in `onChanges` should run, and the view should then be updated to reflect the model's current value.
**Minimal reproduction of the problem with instructions**
http://plnkr.co/edit/g9niPnLsUy6wWbzm0mHi?p=preview
**What is the motivation / use case for changing the behavior?**
`[ngModel]` should always reflect the model value.
**Please tell us about your environment:**
Mac OS X Sierra, IntelliJ IDEA
* **Angular version:**
2.2.0
* **Browser:**
all
* **Language:** [all | TypeScript X.X | ES6/7 | ES5]
TypeScript 2.0.2
贡献指南
调研方向
从链接的 Plunker 复现开始,检查使用 [ngModel] 和 (ngModelChange) 的复选框,然后跟踪模型更新如何到达视图。通过确保复选框在 onChanges 运行后反映当前模型值来确认修复,包括处理程序期间所做的更改。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100