我们已经列出了具有比较功能的产品(在复选框中)。转到下一页时,复选框未选中。我们尝试下面的代码,但是我们不能修复这些问题。
在视图页面中
<div class="compare-opt">Compare <input type="checkbox" id='compare_{{inventorys.id}}' ng-click="CompareVehicleList(inventorys.id,'List')" ng-checked="CompareCheck(inventorys.id)"></div>在Angularjs控制器中
$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;
}}
发布于 2016-02-12 12:56:10
最终我得到了解决方案,
$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;
}}
https://stackoverflow.com/questions/35354963
复制相似问题