Checklist using an array to filter a list


#1

i try to filter (BRANDS) from a list of (PRODUCTS) with checklist using an array.
i succeed display the list of check boxes according to the brands i have ($scope.brands),
when i check the “all brands” it check the entire list which is good,
but when i check each brand it also check all the list, i like it to check each brand and add to the $scope.user array so i can use it to filter my PRODUCTS list later…

this is my controller:

function ($scope, $stateParams, ServDataProducts) {    
$scope.brands = ServDataProducts.productsBrands; 
  $scope.user = {brands: ['user']};
  $scope.checkAll = function() {$scope.user.brands = angular.copy($scope.brands);};
  $scope.uncheckAll = function() {$scope.user.brands = [];};
}

and this is my html:

<form class="list">
  <ion-checkbox ng-model="user.brands" ng-value="brand" class="checkbox-calm item-checkbox-right">All Brands</ion-checkbox>
  <ion-checkbox ng-repeat="brand in brands" ng-model="user.brands" checklist-value="brand.brand" class="checkbox-calm item-checkbox-right">{{brand.brand}}</ion-checkbox>
</form>

#2

anyone can help in here…?