DatePicker not updating ngModel value
See original GitHub issueBug?
I have this Date Picker
example
<mat-form-field>
<input matInput [(ngModel)]="from" [matDatepicker]="from" (change)="onChangeEvent($event)" placeholder="From">
<mat-datepicker-toggle matSuffix [for]="from"></mat-datepicker-toggle>
<mat-datepicker #from></mat-datepicker>
</mat-form-field>
import {Component} from '@angular/core';
@Component({
selector: 'date-filter',
templateUrl: 'date.filter.html',
})
export class DateFilter {
from: any;
onChangeEvent(e): void {
console.log(e.target.value);
console.log('this.from = ', this.from);
}
}
What is the expected behavior?
On date change i should have the value in this.form
.
What is the current behavior?
It doesn’t update the model and i get this error: Uncaught Error: Cannot assign to a reference or variable!
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Datepicker does not update ng-model - Stack Overflow
Try creating a variable 'date' in your service and update the variable when the user changes the date. Then, replace {{dt}} with {{date}}...
Read more >date-picker ngModel not work and solution I found
I want use [(ngModel)] to two way binding data, but it is not work. I check the date picker's ts file, found the...
Read more >Datepicker in Angular using mat-datepicker | Material Design
To implement date picker in Angular we can use angular material ... I have created a date variable and bind it to datepicker...
Read more >Datepicker - Angular Material
The datepicker allows users to enter a date either through text input, ... Notice that the emitted value does not affect the current...
Read more >Datepicker selected value - StackBlitz
<mat-datepicker #picker1></mat-datepicker>. </mat-form-field>. <mat-form-field>. <input matInput [matDatepicker]="picker2". placeholder="Angular forms (w/.
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 FreeTop 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
Top GitHub Comments
please use (dateChange)="onValueChange($event) instead of change
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.