TypeScript - Angular 2 - העברת ארגומנט לצינור מותאם אישית


יצרתי צינור שיכול לקבל שני ארגומנטים, אבל אני לא בטוח איך אני יכול לשלוח אותם.

הנה הצינור שלי:

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

והנה ה-HTML שלי

{{ 'searchquery' | translate }}

זה עובד, אבל איך אני יכול להעביר גם capitlize=false? ניסיתי לחפש קצת בגוגל אבל אני לא ממש מוצא דוגמה בדרך שבה אני רוצה לממש את זה (אולי אני עושה את זה לא נכון?)

תודה על העזרה שלך!

תשובה #1

{{ 'searchquery' | translate:false }}

{{ 'searchquery' | translate:'toUsEn' }}