Templarian / ui.bootstrap.contextMenu

AngularJS Bootstrap UI Context Menu
MIT License
259 stars 127 forks source link

Text that comes from $filter('translate')('key') is not dynamically updated #119

Closed Mouradif closed 7 years ago

Mouradif commented 7 years ago

Hi there,

Just a tiny issue here, everything is in the title, I have a menuOption array like this :

    $scope.menuOptions = [
        {
            text: $filter('translate')("admin.invoice.DELETE"),
            click: function($itemScope, $event, modelValue, text, $li) {
                // code here
            }
        }
    ]

But the text in the context menu stays the same as when the page was first loaded

josetaira commented 7 years ago

Hi @Mouradif could you provide a plunker sample of this?

josetaira commented 7 years ago

Nevermind, just try this out instead:

$scope.menuOptions = [
        {
                        // use a function wrapper to return the text
            text: function() { return $filter('translate')("admin.invoice.DELETE"); },
            click: function($itemScope, $event, modelValue, text, $li) {
                // code here
            }
        }
    ]

If the translation is made after the page is loaded, if you don't put it in a wrapper function the old text will not change.

Mouradif commented 7 years ago

It works ! Thanks