angularjs - Empty an array before push -
i took project using angularjs. there filtering system. actually, click on category add category list. industries got category shown. note click on selected category remove category. i click replace filtering category each click not add category. how should modify code: $scope.changercategorie = function(category , name ){ if( jquery.inarray(category, $scope.selected ) !== -1) { angular.foreach($scope.selected , function(obj,index){ if( category == obj ){ $scope.selected.splice(index,1); $scope.selected_name.splice(index,1); } }); }else{ $scope.selected.push(category); $scope.selected_name.push(name); } $scope.selected_filter = $scope.selected.join(', '); } i tried doesn't work $scope.changercategorie = function(category , name ){ $scope.selected = 0; $scope.selected_name = 0; $scope.selected = category; $scope.selected_name = ...