The ngModel is not working. I'm using it with textbox.
app.component.html
<input type="text" [value]="name" [ngModel]="name">
Name is: {{name}}
app.component.ts
name = '';
constructor() { }
ngOnInit(): void {
this.name = "Hello";
}
When I change the textbox value, the value is not changing in the component. But the two-way data binding is working with [(ngModel)]="name". Please help.
From
ngModeldescription,Either you can work with
[(ngModel)], the two-way binding as you mentioned,or you need to have the
(ngModelChange)event binding to update the variable with the input's value.Demo @ StackBlitz