Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

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;