Usage
import { numAttr } from 'ngwr/utils';
readonly speed = input(4, { transform: numAttr(4) });
// <wr-thing speed="12" /> → 12 (string attribute coerced)
// <wr-thing [speed]="x" /> → x ?? 4Why ngwr provides this
Angular's own numberAttribute falls back to NaN, which then needs guarding at every read. Wrapping coerceNumberProperty with a declared fallback keeps templates free to pass strings, numbers, or nothing — every numeric input in the kit uses it, so it's exported for app inputs too.
// Angular built-in: NaN fallback leaks into your math.
readonly a = input(0, { transform: numberAttribute }); // 'abc' → NaN
// ngwr: declared fallback.
readonly b = input(4, { transform: numAttr(4) }); // 'abc' → 4API
| Name | Description | Type | Default |
|---|---|---|---|
numAttr | Returns an input transform that coerces to number with a fallback. | (fallback: number) => (value: unknown) => number | — |