Search code examples
angularjscheckboxangular-filters

Dynamic multiple checkbox filter in angular JS


I am using the checkbox filter from this link. It works fine but how to change it to select multiple checkbox's. Now it works for only 1 checkbox selection.

http://jsfiddle.net/HWa2m/243/

<input type="checkbox" data-ng-model="useBrands[brand]" />
                        {{brand}} <span>({{ (filteredProducts | filter:searchTerm | filter:count('Brand', brand)).length }})</span> </label>

Solution

  • Change

    <div data-ng-repeat="brand in brandsGroup | limitTo: maxBrands" data-ng-if="(filteredProducts | filter:searchTerm | filter:count('Brand', brand)).length > 0">
    

    To

    <div data-ng-repeat="brand in brandsGroup | limitTo: maxBrands" >
    

    And

    {{brand}} <span>({{ (filteredProducts | filter:searchTerm | filter:count('Brand', brand)).length }})</span> 
    

    To

    {{brand}} <span>({{ (products | filter:searchTerm | filter:count('Brand', brand)).length }})</span>