I'm having some trouble filtering an list by type (number) in angular (1.5.8)
my ng repeat with filter is as following:
ng-repeat="activity in guild.history_updates | filter : {
action_type: filters.action_type,
user_id: filters.user,
}"
and my filter
<md-input-container class="md-block">
<label>Type</label>
<md-select ng-model="filters.action_type">
<md-option>
All
</md-option>
<md-option ng-repeat="action_type in guildActivityCtrl.action_types"
ng-value="action_type.type">
{{action_type.name}} ({{ action_type.type }})
</md-option>
</md-select>
</md-input-container>
When I'm filtering on action_type 1 I'm also getting action types 10
But when I chage the filter to 10, I'm getting the right results
Every other action type is filtered good as well (e.g. action_type 3)
ng-repeat="activity in guild.history_updates | filter:{action_type:filters.action_type,user_id: filters.user}:true"
Adding ":true" after your filter should change this to a strict equality check, now comparing the numeric values.
Hope this helps.
https://docs.angularjs.org/api/ng/filter/filter
The Arguments section defines the comparator.