Reputation: 121
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 <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;
}
}
Upvotes: 1
Views: 120
Reputation: 121
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;
}
}
Upvotes: 1