Home > Back-end >  Angular: Print variable inside another
Angular: Print variable inside another

Time:12-08

I have a variable {{type}} that I want to pass to another field called {{"SUB-MENU-PLACES.{{type}}"}}. But if I write that, what I get is an error, and I don't known how to print that certain variable inside another variable.

enter image description here

If someone could told me how to print that variable correctly on my HTML. Thanks in advanced!

CodePudding user response:

{{ SUB-MENU-PLACES[beach] | translate }}

Use the square brackets property accessor instead of the dot property accessor.

CodePudding user response:

The way you are trying to do it is not a good practice, but i think this is what you asked for:

{{ 'SUB-MENU-PLACES.'   type | translate }}

For this to work the translation key SUB-MENU-PLACES.beach has to exist in your translation file of course.

  • Related