You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
if we clear the number input value(make it empty) ideally filter shouldn't be applied and all values should be listed. Right now if we apply some filter by putting number lets say 5 in input box it works fine and all data matching 5 is listed down. Now if we clear the value in input box, ideally all values should be listed (no filter) but angular applies null filter for numbers and everything is filtered out (ng-repeat doesn't list anything).
input type="number" ng-model="age"
filter:age
Note: No issue with type=text input
The text was updated successfully, but these errors were encountered:
(As you mentioned) this happens because input[number] assigns null to the model when the field is empty.
Expecting this to work the way you expect it to is reasonable (imo), but I am not sure how we could address this.
Fixing it on the filter side is not desirable, because null can be a valid value to look for (and we can't treat it as undefined). Fixing it on the NgModelController is probably not a viable solution either.
I know this post is kinda old but i had a really bad time figuring out how to solve this problem so I want to share my solution. Add a oninput event to your input field and in the javascript function check if the value of this field is an empty string, if so delete the value of the input field with:
delete document.getElementById('whatever').value;
if we clear the number input value(make it empty) ideally filter shouldn't be applied and all values should be listed. Right now if we apply some filter by putting number lets say 5 in input box it works fine and all data matching 5 is listed down. Now if we clear the value in input box, ideally all values should be listed (no filter) but angular applies null filter for numbers and everything is filtered out (ng-repeat doesn't list anything).
input type="number" ng-model="age"
filter:age
Note: No issue with type=text input
The text was updated successfully, but these errors were encountered: