Is there a way to re-render AngularJS filters? I am trying to use the angular currency filter that displays the currency symbol based on the language file that's loaded. I need to re-render the filters once I programmatically load the appropriate language file.
From Angular 1.3 filters are stateless which means filters just will update when theirs input have change.
If you want to update your filter ever, you need to make your filters $stateful.
app.filter('translate', translate);
translate.$inject = ['$rootScope'];
function translate($rootScope){
filter.$stateful = true;
return filter;
function filter(str) {
return i18n[$rootScope.currentLang][str];
};
}
Filters will execute on each $digest but this is inadvisable by perfm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With