我有下面的代码中,我使用的本地存储来存储产品的变体光盘ID的阵列时,用户点击每个产品介绍页面上COMPRE:如何删除重复的项目出现在范围变量
“Prdvar”包含产品ID变型的(例如:10,13等)
a.push(JSON.parse(localStorage.getItem('session')));
localStorage.setItem('session', JSON.stringify(a));
$scope.dataVarID = JSON.parse(localStorage.getItem('session'));
alert($scope.dataVarID); //Duplicate values present
$scope.CompareProduct = function() {
a = JSON.parse(localStorage.getItem('session'));
a.push("{ ProductVarient :"+Prdvar+"}");
alert(a);
localStorage.setItem('session', JSON.stringify(a));
};
我的问题是如何去除存在于$ scope.dataVarID重复的项目。
,{ ProductVarient :5},{ ProductVarient :5},{ ProductVarient :5},{ ProductVarient :33}
//我dontknow在 首先,是增加再12,13,12,12
我只需要,{ ProductVarient :5},{ ProductVarient :33}
参数的功能是$ scope.dataVarID? –
$ scope.dataVarID是包含重复值的数组吗?如果是这样,是的。 – Vivz
TypeError:[对象数组]不是一个获取错误的函数。 –