I have a created a pipe which can receive 2 arugments, but I'm not sure how I can sent them.
here's my pipe:
export class TranslationPipe implements PipeTransform {
private capitalize: boolean;
constructor(
private translationService: TranslationService
) {
this.capitalize = true;
}
transform(key: string, capitalize?: boolean): string {
if (typeof capitalize !== "undefined" || capitalize !== null)
this.capitalize = capitalize;
return this.translationService.getTranslation(key, this.capitalize);
}
}
and here is my HTML
{{ 'searchquery' | translate }}
this works, but how can I pass capitlize = false
aswell? I've tried some googling but I can't really find any example the way I want to implement it (maybe I'm doing it wrong?)
thanks for your help!
You can easily pass multiple arguments in pipe in angular 6, angular 7, angular 8, angular 9, angular 10, angular 11, angular 12, angular 13 and angular 14 application. In this example we will create 'descPipe' custom pipe and create dynamic description with multiple parameters.
In your component's template you can use multiple arguments by separating them with colons: {{ myData | myPipe: 'arg1':'arg2':'arg3'... }} Pipes take an array that contains all arguments, so you need to call them like this: new MyPipe().
In an angular application, when we pass any parameters to the pipes, it is called parameterized pipes we can pass n number of parameters to pipes using a colon (:).
{{ 'searchquery' | translate:false }}
{{ 'searchquery' | translate:'toUsEn' }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With