I have a filter row on top of my page. When clicked, a given filter filters the results, and gets highlighted (specific class). When clicking again, the class should be cleared and visually the filter is unselected.
This works fine on desktop, but on mobile, when I click, the filter gets correctly selected (and the results correctly filtered), but when I click again, the filter remains selected, breaking the user experience. If I click again on something else, the filter gets unselected completely as it should - one click to late... ;)
What could be wrong? I tried installing the ngTouch module as well, but doesn't seem to change anything.
HTML:
section.filter-area
.col-xs-3.filter-row(ng-repeat="flt in vm.filters")
.filter(ng-click="vm.filter(flt)" ng-class="{'selected': flt.isSelected}")
.filter-title {{flt.tag}}
.filter-icon
img.filters(src="{{flt.icon}}")
js:
'use strict';
Controller.$inject = ['$http'];
function Controller($http) {
/* other stuff */
vm.filter = function(flt) {
if (flt.isSelected === undefined) {
flt.isSelected = false;
}
flt.isSelected = !flt.isSelected;
if (flt.isSelected) {
activeFilters += 1;
filterProducts(flt);
} else {
activeFilters -= 1;
unselectFilter(flt);
}
}
}