ngx-linky icon indicating copy to clipboard operation
ngx-linky copied to clipboard

Default options for all pipes

Open HugoHeneault opened this issue 8 years ago • 2 comments

First things firsts: thanks for your really cool pipe! :)

I'm working on an ionic app and I need to change the replaceFn for all pipes I use. It would be great if I could set it for the whole linky module instead of pipe by pipe.

How could I do that?

HugoHeneault avatar Feb 28 '18 10:02 HugoHeneault

Hi. Thanks!

You could create your own pipe as a wrapper:

import { Pipe, PipeTransform } from '@angular/core';
import { LinkyPipe } from 'angular-linky';

@Pipe({ name: 'myLinky' })
export class MyLinkyPipe implements PipeTransform {
  transform(value: string, options: any = {}): string {
    // modify options here - add defaults like:
    options.replaceFn = options.replaceFn || yourDefaultReplaceFn;

    return new LinkyPipe().transform(value, options);
  }
}

dzonatan avatar Feb 28 '18 13:02 dzonatan

Cool! I'll use this for now. You can close it if you don't plan to make it one day :) Thanks!

HugoHeneault avatar Feb 28 '18 14:02 HugoHeneault