Angular pipe with parameters – ngx-translate in title tag

The Issue

Using ngx-translate inside the title tag with parameters. This can be applied to any angular pipe that takes parameters. The format is weird, so I’m leaving it here for future reference.

<i class="fa fa-pencil" aria-hidden="true"
           title="{{'Edit x viability filter' | translate:{value: name} }}"
           (click)="openViabilityFilter(viabilityFilter)"></i>

This is an easier way of doing the translations than the ngx-translate docs suggest, shown below:

This is how you do it with the pipe:

<div>{{ 'HELLO' | translate:param }}</div>

And in your component define param like this:

param = {value: 'world'};
Share this:

Leave a comment