I have in my Sample.html
somewhere defined
<input (keydown.Enter)="onKeyEnter($event)" ...
In my Sample.ts
I have defined
onKeyEnter(event: KeyboardEvent): void {
....
event.preventDefault();
event.stopPropagation();
}
I get with strictTemplates
the failure
error TS2345: Argument of type 'Event' is not assignable to parameter of type 'KeyboardEvent'.
Which is somehow strange because in the input
one can get only the a KeyboardEvent
. Is there a way to get rid of this error? Which I see as false positive.
it's not the same event keydown
than keydown.enter
, as the own Angular say
Type 'Event' is missing the following properties from type 'KeyboardEvent': altKey, char, charCode, code, and 16 more.
You can use "any"
onKeyEnter(event: any): void {
}
Update or Event
onKeyEnter(event: Event): void {
}