Problem with property binding reevaluation with a template reference variable
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Expected behavior
In a template I include the following HTML code:
<input type =“text” #query><input type =“submit” [disabled]=“!query.value”>
I expect the the submit button is disabled by default, but when I type something into the input box, it gets enabled since the property binding will be reevaluated in every event cycle. But that is not what is happening. The button stays disabled.
If I change the above code to the following,
<input type =“text” (input)=“0” #query><input type =“submit” [disabled]=“!query.value”>
and add an explicit event binding (which has nothing to do with the template variable itself), it behaves as intended. I think there is an overaggressive optimization is going on, which is not in compliance with what is stated in this page: https://angular.io/guide/architecture
“Angular processes all data bindings once per JavaScript event cycle, from the root of the application component tree through all child components.”
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment
Angular version: 1.6.7
Browser:
- [X] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [X] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: 9.3.0
- Platform: Mac
Others:
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Duplicate of #6618 (
woking as intended
for bug report,not implementable
for feature request), possibly could improve the docs.Seeing a Stack blitz reproduction would be great https://stackblitz.com/fork/angular-gitter