title: How to add or remove list of values in Array based on checkbox selection in AngularJS and dynamic filteration?
body: <pre><code>$scope.selectObjectType = function () {
      $scope.selected = []; // clear previous state
       $scope.model.allItemsSelected = true; // all are selected unless...
       // If any object type is not checked, then uncheck the "allItemsSelected" checkbox
      for (var i = 0; i &lt; $scope.model.objectTypes.length; i++) {
          if (!$scope.model.objectTypes[i].isChecked) { 
               //$scope.selected.splice($scope.model.objectTypes[i].value);
              $scope.model.allItemsSelected = false;
              return; 
          } else {
              if ($scope.selected.indexOf($scope.model.objectTypes[i].value) == -1) {
                  $scope.selected.push($scope.model.objectTypes[i].value);
              }
          }
      }
  };
  
   // Fired when the checkbox "Show All" is checked
  $scope.selectAll = function () {
      // Loop through all the object types and set their isChecked property
      for (var i = 0; i &lt; $scope.model.objectTypes.length; i++) {
          $scope.model.objectTypes[i].isChecked = $scope.model.allItemsSelected;
      }
  };
  </code></pre>
  
  <p>Whenever i am clicking first "Show Activated" and "Show Inactivated" in that list it's adding to the array(selected).
    But if i am clicking " Show InActivated " as first. It's not adding to the array.</p>
  
  <p>Same process for removing.</p>
  
  <p>Please any one help to acheive this requirement.</p>