UtilOptional

numAttr

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

Usage

import { numAttr } from 'ngwr/utils';

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

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

API

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

See also