In order to get the first letter and add an underscore underneath, you can use the following code:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'underlineFirstLetter'
})
export class underlineFirstLetterPipe implements PipeTransform {
transform(value: string, args: any[]): string {
if (value === null) return;
return value.charAt(0).toUpperCase() + '_' + value.slice(1);
}
}
If you want to display the underscore under the first letter, you can modify the code as follows:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'underlineFirstLetter'
})
export class underlineFirstLetterPipe implements PipeTransform {
transform(value: string, args: any[]): string {
if (value === null) return;
return "<u>" + value.charAt(0).toUpperCase() + "</u>" + value.slice(1);
}
}
If it's still not displaying correctly, you may need to adjust the styling accordingly.