I have a regular input text:
<form>
<input type="text" oninput="sendInput()" />
</form>
I want to send what the user typed in the box into the typescript file (without a submit button or something) when the user has finished typing, send the input to the typescript.
I try with this code but it's not working.
Demo use ngModel two way binding
<input type="text" [(ngModel)]="inputParam"/>
<p>{{inputParam}}</p>
Demo or use ViewChild as a way
component.ts
inputParam=""
@ViewChild('input') _input: ElementRef;
sendInput(){
this.inputParam= this._input.nativeElement.value;
}
html part
<form >
<input #input type="text" (input)="sendInput()"/>
</form>
{{inputParam}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With