Last active
October 25, 2019 19:55
-
-
Save mrshawnspencer/43f1a56a92c3e3fbcf8a504e18a91133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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