Matt
Matt

Reputation: 375

Build a string inside component.html (Angular)

I'm using @ngx Translate Service. Inside a template, you can use it this way, where 'stringName' is a key inside a JSON file:

{{ 'stringName.subStringname' | translate }}

My problem is that I have to build the key name inside the template, using a string and a variable (whose value is 'subStringname') from the component.ts. I need to build something like this:

{{ `stringName.${variable}` | translate }}

What's the right synthax?

Upvotes: 0

Views: 156

Answers (1)

duPleX
duPleX

Reputation: 68

Try this:

{{ 'stringName.' + variable | translate }}

Upvotes: 1

Related Questions