Home > database >  Angular html simple binding
Angular html simple binding

Time:07-17

I have used this post to crate binding:

Angular HTML binding

but messed up with an error:

Property 'value' does not exist on type 'EventTarget'.

Wherе might be the point?

html: <input [value]="test" (input)="test = $event.target.value">

"test" is a property of a component.

Question might be stupid, but I have tested different ways to solve the problem and see no way out. Thanks for any help.

CodePudding user response:

<input [value]="test" (input)="onInput($event)">
onInput(event: Event) {
  this.test = ($event.target as HTMLInputElement).value;
}
  • Related