1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'spaceToUnderscore' }) export class SpaceToUnderscorePipe implements PipeTransform { transform(text: string): string { if (text) { // @ts-ignore text = text.replaceAll(' ', '_'); return text; } return text; } }