0

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?

2
  • stringName[variable] try like this and check does it works ? Commented May 27, 2021 at 11:52
  • 1
    See here: codeandweb.com/babeledit/tutorials/… Commented May 27, 2021 at 11:56

1 Answer 1

1

Try this:

{{ 'stringName.' + variable | translate }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.