title: keeping the "checked" value to an input checkbox after search using ng-repeat | Angularjs
body: <p>I have to let the user select items to submit them later on, but my problem occur when selecting multiple items and then search for another items to select them, the previous selected items rested to default values <strong>unchecked</strong>.</p>
  
  <p>how to keep the checked value to the selected items after calling again getAllItems function? because what happens is that the ng-repeat clear the value of the previous selected items.</p>
  
  <p>My view:</p>
  
  <pre><code>&lt;div id="dialog-items"&gt;
           // the search box
          &lt;input ng-change="getAllItemNames(searchValMultiItems)" ng-model="searchValMultiItems" type="text"/&gt;
  
          &lt;table&gt;
              &lt;th&gt;Designation&lt;/th&gt;
              &lt;th&gt;Colisage&lt;/th&gt;
              &lt;th&gt;Code&lt;/th&gt;
              //the mark() function is to set checked value to selected input and store the item in an array
              &lt;tr ng-repeat="d in allDesignation" ng-click="markItem(d.itemName); ischeck=true;"&gt;
                  &lt;td &gt;&lt;input type="checkbox" ng-checked="ischeck" /&gt; {{d.itemName}}&lt;/td&gt;
                  &lt;td&gt;{{d.item_colisage}}&lt;/td&gt;
                  &lt;td&gt;{{d.code}}&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>//calling this function to search for an item
   $scope.getAllItemNames=function(searchValMultiItems){
  
      var searchItems=searchValMultiItems;
  
      var url="../php/mainPageFacture.php";
      var data = {"function":"getAllItemNames","searchValMultiItems":searchItems};
  
      var options={
          type : "get",
          url : url,
          data: data,
          dataType: 'json',
          async : false,
          cache : false,
          success : function(response,status) {
              $scope.allDesignation=response;
              $scope.safeApply(function() {});
  
          },
          error:function(request,response,error){
              alert("Error");
          }
      };
      $.ajax(options);
  }
  
   /*this is responsible to set checked value to true when 
     item is selected and store all selected item in an array*/
   $scope.markItem=function(itemName){
  
      if( $.inArray(itemNameWithCode, multiSelectItem_names) !== -1 ) {
         alert("This Item is already added to this Invoice");
      }else{
          multiSelectItem_names.push(itemNameWithCode);
      }
  }
  </code></pre>
  
  <p>I store all selected items in an array and even after search the array keep the value, but problem is only whith the checked mark, i'll attach a photo for more clarification<a href="https://i.stack.imgur.com/VgiNY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VgiNY.png" alt="Assume that these two items are selected"></a><a href="https://i.stack.imgur.com/LiqI7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LiqI7.png" alt="if is searched for the item, the checked value set cleared "></a></p>