summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/pipes/capitalize/capitalize-and-format.pipe.ts
blob: e3ec9ae9a9e90485f26bec4f672ca8ac0e80afac (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('_', '-');
      return text.charAt(0).toUpperCase() + text.slice(1);
    }
    return text;
  }
}