I'm trying to figure out, how to update interpolated values in an Angular template - if the value itself does not change.
I have statements like this (e.g. a translation):
<div>{{ 'SOME_TAG' | lang }}</div>
This starts a filter
app.filter('lang', function(Locale) {
return function(val) {
return Locale.translate(val);
}
});
Locale is a service that has a field lang, depending on which the values are translated into different languages. When I change the value of this field, the value of the translation should change as well.
Something like
<select ng-model="lang" ng-change="changeLang()">
<option value="de">Deutsch</option>
<option value="en">English</option>
</select>
...
$scope.changeLang = function() {
Locale.changeLanguage($scope.lang);
};
In older AngularJS versions (e.g. 1.1.5, not sure how far) this did the trick just fine. If I update the Locale.lang value and a $digest() cycle runs, the interpolated template values are updated. In the newest version (1.4.6 but also 1.3.xx) this does not work anymore. I assume this is part of some optimization - the value ('SOME_TAG') has not changed, so why rerun the interpolation.
I've seen this http://angular-translate.github.io/ where it works fine. Is there a "trick" to have those values update?
Thank you.