Orane Orane - 1 month ago 9
AngularJS Question

How does quotes inside template expression work in angular1?

I'm working with an existing codebase and I need to figure out how this works:

{{'some_variable' | translate}}


It seems to correlate to
some_variable
in an api call but I don't see it in the controller.

Answer

In this project you are using angular-translate...

This module offers you directive, filter and a service to add translation into your application...

In the example you gave you are using translate filter (if you are not familiar with the angular filters check out documentation)...

There are some options that how angular translate get your translations but at the end it will something like javascript object like this...

{
  some_variable: 'Some Variable translation'  
}

translate filter will take your input 'some_variable' and find value for it from given translations (if it cannot find anything it will return key itself)...