2

In html, {{ 'ShowFullMonth' | translate }} works fine to display some localised text 'Show Full Month'. However, when studying the this similar question and the Angular Docs I cannot see how to adapt this for javascript.

$filter('translate')(['ShowFullMonth']) gives me [object Object].

Any help would be great.

1
  • 3
    Do not pass it as array, use it like this $filter('translate')('ShowFullMonth') Commented Jun 15, 2015 at 13:44

3 Answers 3

4

Try:

$filter('translate')('ShowFullMonth')

Like in your view - you have to pass it a string ;)

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

Comments

2

Angular filter functions do not expect the arguments to be wrapped up in an Array - just pass them normally.

$filter('translate')('ShowFullMonth')

If your filter function took multiple arguments, you'd just pass them normally too:

$filter('myFilter')(param1, param2, param3)

1 Comment

Thanks but Tomek beat you to it.
1

You should execute $filter like this:

$filter('translate')('ShowFullMonth')

instead of:

$filter('translate')(['ShowFullMonth'])

Because in your view it's a string not an array object

1 Comment

Thanks but Tomek beat you to it.

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.