UtilUpdated in v16Optional

wrNumAttr

Input transform that coerces a bound value to a number, with a fallback.

Usage

import { wrNumAttr } from 'ngwr/utils';

readonly speed = input(4, { transform: wrNumAttr(4) });

// speed="12"     gives 12
// speed="abc"    gives 4
// [speed]="null" gives 4

API

NameDescriptionTypeDefault
wrNumAttrReturns an input transform: a number, or fallback for null, undefined and unparsable input.(fallback: number) => (value: unknown) => number—

See also