Search code examples
angularangular-translate

Angular 2+ textarea placeholder conditioned and with translate


conditioned:

<textarea
    class="form-control"
    [placeholder]="(i < 3) ? 'a' : 'b'">
</textarea>

a a a b b b b b b b b b

with translate:

<textarea
    class="form-control"
    placeholder="{{'STEPS.PLACEHOLDER' | translate}} {{title$ | async}}"
</textarea>

Title is foo

but I need conditioned and with translate:

<textarea
    class="form-control"
    ?placeholder?="?????"
</textarea>

1st title is foo

2nd title is foo

3th title is foo

next title is foo

next title is foo

next title is foo

next title is foo

next title is foo


Solution

  • <textarea
        class="form-control"
        [placeholder]="(i < 3) ? ('STEPS.PLACEHOLDER_' + i | translate) + ' ' + (title$ | async) : ('STEPS.PLACEHOLDER_ELSE' | translate) + ' ' + (title$ | async)"
    </textarea>