Ionic grid : exclude duplicate items

hi all,
i tray to draw a dynamic grid,
and need to exclude some duplicate items.

i’m using http.post, parsing a data and displaying a grid, as bellow.
every thing work fine, except excluding duplicate (key,value).

  • Total grid are (data.nbr_cellule) = 40
  • Total Elements via wsAPI.getElements = 10
  • each wsAPI.getElements element has a cellule id

i need a solution to check if ( $scope.items[i].cellule != i )=> don’t work.
(
duplicate ids :

  • 10
  • 13
  • 19
  • 31
  • 32

    )

thanks a lot

wsAPI.getElements(params).then(function(data) {
$scope.items = data.Elements;

                if ( data.statut == 1 ) {
                    for (var i = 0; i < data.nbr_cellule; i++) {
                            if( $scope.items[i].cellule != i) {
                                $scope.items.push(
                                    {
                                        "statut":"",
                                        "conseils":"",
                                        "video":"",
                                        "cellule":i,
                                        "image": "",
                                        "code_html": "#eeeeee",
                                        "code_rgb": "",
                                        "idt":""
                                    }
                                );
                            }
                        }
                    }

            },function(){
                $scope.error = true;
            });

fixed. bellow the solution.

                var cel_ids_exclude = [];
                for (var j = 0; j < data.Elements.length; j++) {
                    cel_ids_exclude.push(data.Elements[j].cellule);
                };

and then :

if(cel_ids_exclude.indexOf(i) == -1){
$scope.items.push(
{