File

src/app/pipes/string/replace/replace.pipe.ts

Description

Replace pipe

Example

Metadata

name replace

Methods

transform
transform(input: any, pattern: any, replacement: any)
Parameters :
Name Type Optional Description
input any
pattern any
replacement any
Returns : any
import { Pipe, PipeTransform } from '@angular/core';
import { isString } from 'util';

/**
 * Replace pipe
 * @author Daniel Sogl
 */
@Pipe({
  name: 'replace'
})
export class ReplacePipe implements PipeTransform {
  transform(input: any, pattern: any, replacement: any): any {
    if (!isString(input) || !pattern || !replacement) {
      return input;
    }

    return input.replace(pattern, replacement);
  }
}

results matching ""

    No results matching ""