-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Way to update / re-calculate filtered values #7556
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
Stateful filters are a bad idea, that was explicitly removed in Vue 2.0. Method calls that refers to reactive state should update automatically, so it's either that your state is not reactive, or it's a bug. If you believe it's bug, please open a bug report with reproduction. |
Method does not refer to a reactive state, i wanted to use the global value.
|
You can define a reactive property on translate method. |
Thanks! this.$forceUpdate() worked in component but not in new Vue() instance. |
What problem does this feature solve?
Hi! In Angular 1.x filters i can use $stateful, and values updated automatically
<div>{{'any-key' | translate }}</div>
module.filter('translate', function($rootScope) {
function translate(value) {
return $rootScope.translate[value] || value;
};
translate.$stateful = true;
return translate;
});
In VUE:
Filters not recalculate, and in filter "this" is undefined
<div>{{'any-key' | translate}}</div>
Methods not recalculate
<div>{{translate('any-key')}}</div>
Methods and Filters not recalculate, when i use this.$forceUpdate() method
What does the proposed API look like?
1 "this" link in filters for use context data.
Vue.filter('translate', function(value) => {
return this.$store.translate[value] || value;
});
2 auto or manually re-render value when i change Object this.$store.translate
The text was updated successfully, but these errors were encountered: