Input property doesn't change value
See original GitHub issueπ bug report
Description
I created a component with some input properties. I use two-way binding for one property and change value inside the component and then change it in a parent component. After some actions, value stops changing.π¬ Minimal Reproduction
- Change the value of the input.
- You can see βValidation messageβ
- Then type again -> βValidation messageβ is gone
- After the next typings message doesnβt appear
But I want to see the message after changes.
π₯ Exception or Error
π Your Environment
Angular Version:
Anything else relevant?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Angular Input value doesn't change - Stack Overflow
Now when I click on an object in the parent component, the details will be loaded in de detail component, but when I...
Read more >How to detect @input value changes in Angular Child ...
In this tutorial we learn how to detect @input value changes in Angular Child component with simple examples. Table of Contents Using @input...
Read more >Why Angular Input Setter is Only Being Fired Once
Thus if we pass into the input property with an observable object which contains the same value, Angular will take it as a...
Read more >How to detect when an input() value changes in Angular
Detect when input value changes in Angular Β· 1. Using the ngOnChanges() lifecycle method Β· 2. Using Input Setter and Getter Property Β·...
Read more >How to detect when an @Input() value changes in Angular?
@Input() is basically a decorator to bind a property as an input. It is used to pass data i.e property binding from one...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

when the βchangeβ event of this input
<input (change)="handler($event)" />gets triggered, you first do this:
this.isValid = true;and then you emit your output with
this.valueChanged.emit(e.target.value);on which app.component is listening on, which does this:
this.isValid = false;Notice that the βisValidβ variable of app.component is in turn bound to the ngModel of βmy.componentβ
Basically, before Angularβs change detection can run you are changing the input value twice, bringing it always back to itβs invalid value, therefore Angular cannot pickup any change.
As a test, change this in app.component:
valChanged(val: string) { if (val !== "test") { this.isValid = false; } }to this:
valChanged(val: string) { if (val !== "test") { setTimeout(()=> {this.isValid = false}); } }Welcome to Change Detection
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.