import { numAttr } from 'ngwr/utils';
readonly speed = input(4, { transform: numAttr(4) });
// speed="12" gives 12
// speed="abc" gives 4
// [speed]="null" gives 4numAttr
Input transform that coerces a bound value to a number, with a fallback.
Usage
API
| Name | Description | Type | Default |
|---|---|---|---|
numAttr | Returns an input transform: a number, or fallback for null, undefined and unparsable input. | (fallback: number) => (value: unknown) => number | — |