-
Notifications
You must be signed in to change notification settings - Fork 80
Text on the Dropdown-Button isn't updating #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a design flaw for this particular case. As text in button is the compile result of the dropdown item, no expression will be actually added to the button. so when you model |
Thank you for the fast replay. Is there a way to rerender the dropdown or to force the update? |
Here is a way to make the button update when you change the translate service. It may looks clunky, but should works Your case is using It may looks like this // In your controller, assume that you are using the angular-translate
var changeLanguage = function() {
$scope.selected.item.forEach(function(value,key) {
value.name = $filter('translate')(value.name);
});
} |
Thank your for your tip, but unfortunately this would destroy the marker for the translation, so i can only use this function once. I solve the problem by using a third attribute called "translation" like:
And with this Object i use the Function like:
This fixed my problem. |
As you can see I'm using a filter called "translate" on the labels in the dropdown and the label on the button. The filter translate a marker into the right translation for example, "ITEM_PAPER" into "Paper", when the language is set to english.
When I'm loading the page everything works fine but when I'm change the language for the site, only the items in the dropdown change not the button label.
And as you can see i tried it with "deep-watch=true" but this doesnt work neither.
My object looks something like that:
$scope. selected.item = [ { "value": "1", "name": "ITEM_PAPER" }, { "value": "2", "name": "ITEM_CLOCK" }, { "value": "3", "name": "ITEM_PEN" } ]
The model looks like this:
$scope.model.language = 1;
My Global config looks like this:
$scope.translate_config={ maxItems: 1, valueField: 'value', labelField: 'name', searchField: ['name'] };
For my regret i can't provide you with a working plunker or fiddle because the whole application with the translation thing is just to big and time consuming to bring it into a plunker or fiddle.
The text was updated successfully, but these errors were encountered: