summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.ts
blob: 12b1eb912c28078ad032d25a911107cf4e332bad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import {PipeTransform, Pipe} from '@angular/core';

@Pipe({ name: 'capitalizeAndFormat' })
export class CapitalizeAndFormatPipe implements PipeTransform {
  transform(text: string): string {
    if (text) {
      text = text.toLowerCase().replace(/_/g, '-');
      return text.charAt(0).toUpperCase() + text.slice(1);
    }
    return text;
  }
}