import { Pipe , PipeTransform , Component } from '@angular/core' ; @ Pipe ( { name : 'capitalize' } ) export class CapitalizePipe implements PipeTransform { transform ( value , arg ? ) { if ( value == null ) { return null ; } let length = value . length ; if ( length === 0 ) { return '' ; } else if ( length === 1 ) { return value . toUpperCase ( ) ; } else if ( length >= 2 ) { return value [ 0 ] . toUpperCase ( ) + value . substring ( 1 ) ; } } }