File

libs/age-range/src/enum-to-range.pipe.ts

Metadata

name enumToRange

Methods

transform
transform(value: any, _args?: any)
Parameters :
Name Type Optional
value any no
_args any yes
Returns : any
import { Pipe, PipeTransform } from '@angular/core';

import { ageRanges } from './age-ranges';

@Pipe({
  name: 'enumToRange'
})
export class EnumToRangePipe implements PipeTransform {

  transform(value: any, _args?: any): any {
    try {
      const index = parseInt(value, 10);
      return ageRanges[index].label;
    } catch (error) {
      return null;
    }
  }
}

results matching ""

    No results matching ""