1

We have listing the products with the compare feature ( in checkbox). while go to next page, checkbox is unchecked. we try the following code, but we cant fix the issues.

In the View Page

<div class="compare-opt">Compare &nbsp;<input type="checkbox" id='compare_{{inventorys.id}}'  ng-click="CompareVehicleList(inventorys.id,'List')" ng-checked="CompareCheck(inventorys.id)"></div>

In the Angularjs controller

$scope.CompareCheck=function(current_id){
  var cmp_list = $cookieStore.get("CompareList").split(",");
  if(cmp_list.length>0){
    angular.forEach(cmp_list, function(item) {
      if(parseInt(item) === parseInt(current_id)){        
        return true;
      }else{
        return false;
      }
    });
  }else{
    return false;
  }

}

1 Answer 1

1

Finally i got the solution,

$scope.CompareCheck=function(current_id){

  var cmp_list = $cookieStore.get("CompareList").split(",");
  if(cmp_list.length>0){
   for(j=0; j<cmp_list.length;j++){
       if(parseInt(cmp_list[j]) == parseInt(current_id)){  
          return true;
        }
   }

  }else{
    return false;
  }

}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.