Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
Say hello to Angular's future home!Check out Angular.devHome
/

numberAttribute

Transforms a value (typically a string) to a number. Intended to be used as a transform function of an input.

      
      numberAttribute(value: unknown, fallbackValue: number = NaN): number
    
Parameters
value unknown

Value to be transformed.

fallbackValue number

Value to use if the provided value can't be parsed as a number.

Optional. Default is NaN.

Returns

number

Usage notes

      
      @Input({ transform: numberAttribute }) id!: number;