Created
December 27, 2016 16:22
-
-
Save sangress/edf38e7e574e10e89c8e90821178a0df to your computer and use it in GitHub Desktop.
Angular2 replace pipe
This file contains hidden or 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
import { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'replace' | |
}) | |
export class ReplacePipe implements PipeTransform { | |
transform(value: string, expr: any, arg2: string): any { | |
if (!value) | |
return value; | |
return value.replace(new RegExp(expr, 'gi'), arg2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello ! Thanks to share this tip. Can you explain how to use it (in a comment block)?