ng2-pipes
Version:
Useful angular2 pipes
12 lines (9 loc) • 335 B
text/typescript
import {PipeTransform, Pipe, Injectable} from '@angular/core';
()
({name: 'scan'})
export class ScanPipe implements PipeTransform {
transform(text:string, args: string[] = []):string {
return text.replace(/\{(\d+)}/g, (match, index) =>
typeof (args[index]) !== 'undefined' ? args[index] : match);
}
}