import { Injectable , Pipe , PipeTransform } from '@angular/core' ; @ Pipe ( { name : 'capitalize' } ) @ Injectable ( ) export class CapitalizePipe implements PipeTransform { transform ( value , onlyFirst ) { if ( onlyFirst ) return value . charAt ( 0 ) . toUpperCase ( ) + value . substr ( 1 ) ; let words = value . split ( ' ' ) ; let output = '' ; words . forEach ( ( value , index , words ) => { output += value . charAt ( 0 ) . toUpperCase ( ) + value . substr ( 1 ) . toLowerCase ( ) + ' ' ; } ) ; return output ; } }