'Angular Ivy strictTemplates Argument of type 'Event' is not assignable to parameter of type 'InputEvent'
I really don't understand what's the problem is with this code
<input #quantity type="number" matInput formControlName="quantity" (input)="onQuantity($event, i)" placeholder="Quantity"/>
onQuantity(event: InputEvent, i: number) {
if (!this.totals[i]) {
this.totals[i] = { price: '0', quantity: 1 };
}
let value = (event.target as HTMLInputElement).value;
value = value ? value : '0';
this.totals[i].quantity = parseInt(value, 10);
}
The compiler get an error Argument of type 'Event' is not assignable to parameter of type 'InputEvent'. and if I use
onQuantity(event: Event, i: number)
I get Type 'Event' is missing the following properties from type 'InputEvent': data, inputType, isComposing, detail, and 2 more.
so I don't known what way to turn :( Can anyone help me, please?
UPDATE
I have worked it out with
(input)="onQuantity(quantity.value, i)"
Solution 1:[1]
change event belongs to InputEvent type interface
Try this:
onQuantity(event: InputEvent, i: number){}
Solution 2:[2]
Please use this
onQuantity(event:InputEvent, i: number){
// do your operation
}
the type of event is InputEvent.
You can check it by using console.log(event)
For me it gives

Solution 3:[3]
use (input)="onQuantity($any($event), i)" in html template
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Chellappan வ |
| Solution 2 | Shlok Nangia |
| Solution 3 | Utsav Sharma |
