I am attempting to create a custom pipe that will replace one character with another (use case: replacing hyphenated words with space separated words), but I cannot seem to get it working after following online guides and the Angular docs.
pipe.ts
@Pipe({
name: 'replace'
})
export class ReplacePipe implements PipeTransform {
transform(value: string, replace: string, withThis: string): any {
return value.replace(replace, withThis);
}
}
html usage
<!-- hyphenate = 'some-hyphenated-string' -->
<div>{{hyphenated | replace: {replace: '-', withThis: ' '} }}</div>