0

I am newbee to angular and have this filter to translate the text (localization) which works well in my html/view:

<input type="button" class="btn btn-link" value="{{'weeklyOrdersPage.reposting' | translate}}" ng-click="sortBy('reposting')" />

What this does is to take the value from one resource file and display text and it works very well.

Now, I need to do something similar in controller where I am rendering a google map using javascript api. I need to set the text of the marker based on the language i choose. I tried this and it didn't work:

var markerConter = '<div class="infoWindowContent">' +
                                       '<div><b>' + $filter('translate')("{{'weeklyOrdersPage.panelId'}}") + ': </b>' + panel.id + '</div>' +
                                       '<div><b>' + $filter('translate')("{{'weeklyOrdersPage.panelClassification'}}") + ': </b>' + panel.panelClassification + '</div>' +
                                       '<div><b>' + $filter('translate')('{{weeklyOrdersPage.quality}}') + ': </b>' + panel.format + '</div>'
                    '</div>';

Any pointers on how to move forward?

1 Answer 1

1

You don't need to use {{}} when writing code in controller

$filter('translate')('weeklyOrdersPage.panelId')
$filter('translate')('weeklyOrdersPage.panelClassification')
$filter('translate')('weeklyOrdersPage.quality')

That should solve the problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks....works like a charm. Only thing i had to do was to include quotes around each key.

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.