-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Unable to watch the changes of the property '$' of an object which is used by filterFilter. #13313
Comments
@javeme You could supplement your watch with value of this property directly... //object to search
$scope.search = {
'$': 'something...',
// ... other filtering properties
};
function filterResults() {
results = filter(list, search);
}
// watch the search object (except the `$` property)
$scope.$watch('search', filterResults, true);
// watch the `$` property
$scope.$watch('search.$', filterResults); This would not work for situations where Perhaps this is another use case for #10096 |
@petebacondarwin Thanks for your solution, if we already know the bug we could bypass it. but it would be better If we can completely solve it. |
Perhaps the easiest solution here would be to allow the "match any property" identifier symbol (currently The //object to search
$scope.search = {
'%': 'something...',
// ... other filtering properties
};
function filterResults() {
results = filter(list, search, undefined, '%');
}
// watch the search object (including the `%` property)
$scope.$watch('search', filterResults, true); Now the watch would pick up changes to the @gkalpak do you have any thoughts on this? |
@petebacondarwin, your suggestion sounds reasonable. It should be easy to implement and not introducing any BC, so why not ? #10096 would offer an equally good solution (but both can co-exist). I am fine with both. Admittedly, it wasn't a great choice to use If we considered this a bug and wanted to fix it, maybe we could add an extra check, wherever we check (and ignore) properties starting with So, all things considered, I think @petebacondarwin's suggestion gives the best "value-for-money" 😃 |
PRs welcome! |
Nah...Angular has (almost) always taken pride in having a large community and a great team. There's no person in Angular, it's always a team. I didn't mean to be judgemental in any case 😃
Are you sure ? It seems that the special That said, I obviously spoke too soon. It's the other way around: |
Previously, the special property name that would match against any property was hard-coded to `$`. With this commit, the user can specify an arbitrary property name, by passing a 4th argument to `filterFilter()`. E.g.: ```js var items = [{foo: 'bar'}, {baz: 'qux'}]; var expr = {'%': 'bar'}; console.log(filterFilter(items, expr, null, '%')); // [{foo: 'bar'}] ``` Fixes angular#13313
Previously, the special property name that would match against any property was hard-coded to `$`. With this commit, the user can specify an arbitrary property name, by passing a 4th argument to `filterFilter()`. E.g.: ```js var items = [{foo: 'bar'}, {baz: 'qux'}]; var expr = {'%': 'bar'}; console.log(filterFilter(items, expr, null, '%')); // [{foo: 'bar'}] ``` Fixes angular#13313
Previously, the special property name that would match against any property was hard-coded to `$`. With this commit, the user can specify an arbitrary property name, by passing a 4th argument to `filterFilter()`. E.g.: ```js var items = [{foo: 'bar'}, {baz: 'qux'}]; var expr = {'%': 'bar'}; console.log(filterFilter(items, expr, null, '%')); // [{foo: 'bar'}] ``` Fixes #13313 PR (#13356)
Previously, the special property name that would match against any property was hard-coded to `$`. With this commit, the user can specify an arbitrary property name, by passing a 4th argument to `filterFilter()`. E.g.: ```js var items = [{foo: 'bar'}, {baz: 'qux'}]; var expr = {'%': 'bar'}; console.log(filterFilter(items, expr, null, '%')); // [{foo: 'bar'}] ``` Fixes #13313 PR (#13356)
Unable to watch the changes of the property '$' of an object which is used by filterFilter.
The "$" in the function filterFilter represents any property, however it represents built-in variable in the function equals(watch).
How to resolve the conflict between them?
filterFilter: https://github.com/angular/angular.js/blob/master/src/ng/filter/filter.js#L235
equals(watch): https://github.com/angular/angular.js/blob/master/src/Angular.js#L992
Smart-Table: https://github.com/lorenzofox3/Smart-Table/blob/master/src/stTable.js#L122
The text was updated successfully, but these errors were encountered: