onchange
Description
Fires when a number is changed in the counterUsage
onchange?: (ev: { value: number; input?: boolean }) => void;
Parameters
value- (required) the value of the inputinput- (optional) true, if a value is being typed (check details)
Example
<script>
function handleChange(ev){
const newValue = ev;
console.log(newValue);
// => {value: 2, input: true}
}
</script>
<Counter value={1} onchange={handleChange}/>
Details
The handler function receives the new value of the counter typed in the input. The received object may also contain input:true, depending on the fired HTML input event:
- if the input event of the HTML input is caught (a number is being typed), the
changeevent of the Counter control will haveinput:true - if the change event of the HTML input is caught (a user has applied changes), the
changeevent of the Counter control won't have theinputproperty
Related article: Catching the change of the value