Add distinct items to an array in angularjs -
i'm trying add array distinct item error appears "referenceerror: $ not defined"
function unique(list) { var result = []; $.each(list, function(i, e) { if ($.inarray(e, result) == -1) result.push(e); }); return result; }
it seems didn't load jquery.
btw implement function don't need that.
try this:
function unique(list) { var result = []; (var = list.length - 1; >= 0; i--) { if (result.indexof(list[i]) == -1) { result.push(list[i]); } }; return result; }
Comments
Post a Comment