Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default options for all pipes #7

Open
HugoHeneault opened this issue Feb 28, 2018 · 2 comments
Open

Default options for all pipes #7

HugoHeneault opened this issue Feb 28, 2018 · 2 comments

Comments

@HugoHeneault
Copy link

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?

@dzonatan
Copy link
Owner

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);
  }
}

@HugoHeneault
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants