Skip to content

Instantly share code, notes, and snippets.

@mrshawnspencer
Last active October 25, 2019 19:55
Show Gist options
  • Save mrshawnspencer/43f1a56a92c3e3fbcf8a504e18a91133 to your computer and use it in GitHub Desktop.
Save mrshawnspencer/43f1a56a92c3e3fbcf8a504e18a91133 to your computer and use it in GitHub Desktop.
/*
Simple Custom Pipe Example
Angular 7/8
(must be imported in the module where it is needed, after imports[], in the declarations[] section)
convert-chars-to-spaces.pipe.ts
*/
@Pipe({
name: 'convertCharsToSpaces'
})
import { Pipe, PipeTransform } from '@angular/core';
export class ConvertCharsToSpacesPipe implements PipeTransform {
transform(value: string, character: string): string {
return value.replace(character, ' ');
}
}
/*
Usage:
*/
<span>{{ healthPlan.healthPlanCode | convertCharsToSpaces: '-' }}</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment