I'm new to Angular.I'm trying to get the user input of a text box in each keystroke and append it to a string variable like on java.
in the text box I use (keyup)="onKey($event)" as follows,
<input type="text" class="form-control" id="inlineFormInputGroupUsername" placeholder="Departure Airport" id="departure" name="departure" (keyup)="onKey($event)" [(ngModel)]="booking.departure" >
Then I used that and tried to append each letter entered to a variable as follows
export class BookingComponent implements OnInit {
public userInPut="";
constructor(private flightService:FlightService, private router: Router) { }
ngOnInit(): void {
}
onKey(event: any){
this.userInPut=this.userInPut+event;
console.log(this.userInPut);
}
}
I expected that the output would be a,ab,abc,abcd like that but the out put was a set of objects as shown in the figure below

What I wanted to do was display that userInPut variable value under the textbox.Are all variables created in typescript are object form.Please give me a clarification and get the expected output.
[object KeyboardEvent]. Have a look at the documentation what properties aKeyboardEventhas and what might solve your problem.[(ngModel)]? Do you really need to listen for each keystroke?