Avoid to duplicate data in table

Hi how can i avoid to duplicate data in table??? i get data from http.get and i need to put data in a table, after if i make the same http.get i need just to update table and not duplicate data.Thanks in advance

You can use angular filters for this like this one or make your own.

hi…this is the function to read table
$rootScope.allODLC2 = [];
$scope.selectAllODLC2 = function() {
var queryB = “SELECT * FROM Tab_OdL2_Temp”;
$rootScope.allODL2 = [];
$cordovaSQLite.execute(db, queryB, []).then(function(res) {
if(res.rows.length > 0) {

            for(var i = 0; i < res.rows.length; i++) {
                 
               $rootScope.allODLC2.push({
                caseFolderId: res.rows.item(i).caseFolderId,        
                DV_EBELN_ODA: res.rows.item(i).DV_EBELN_ODA,
                DV_AEDAT_ODA: res.rows.item(i).DV_AEDAT_ODA,
                DV_EKGRP_EKNAM_ODA: res.rows.item(i).DV_EKGRP_EKNAM_ODA,
                DV_NETPR_WAERS_ODA: res.rows.item(i).DV_NETPR_WAERS_ODA,
                DV_StatoPraticaOdA: res.rows.item(i).DV_StatoPraticaOdA,
                DV_NAME_ODA: res.rows.item(i).DV_NAME_ODA,
                DV_NAME_CR: res.rows.item(i).DV_NAME_CR,
                DateCreated: res.rows.item(i).DateCreated,
                DV_Caseidentifier_for_eni_OdA: res.rows.item(i).DV_Caseidentifier_for_eni_OdA,
                });

              $rootScope.allODLJSON2 = JSON.stringify($rootScope.allODL2);
             //console.log("json Tabella_OdL" + JSON.stringify($rootScope.allODL));
            }
        } else {
            console.log("No results found ODL");
        }
    }, function (err) {
        console.error(err);
    });

}

and in the view

<div ng-init="selectAllPush();selectAllODLC2()">
 <ion-list class="wrapword">

  <ion-item ng-repeat="session in allSessions | filter: searchQuery | orderBy:sortType:sortReverse" class="wrapword" href="#/app/detailRda/{{session.id}}">



    <span class="note-data">{{session.data_inserimento | date :"dd/MM/yyyy"}}</span>
    <br>       
    <p id="rdaTit">RDA numero: <span class="note">{{session.rda_numero}}</span></p>
    
    <p>Oggetto: <span class="note">{{session.oggetto}}</span></p>
    
    <p>Fornitore: <span class="note">{{session.fornitore}}</span></p>
    
    <p>Importo: <span class="note">{{session.importo}}</span></p>
    
    <p>Richiedente: <span class="note">{{session.richiedente}}</span></p>
  
  
    </ion-item>
  </ion-list> 
</div>

if i do the http.get there is no duplication…i have the update…but if i call the function
selectAllODLC2
to show results i duplicate every time i call it…so it is e view problem…because if i restart the app the count retun the right number on the badge

As i said you can filter collection that already inserted to scope via filter, but i think its better to remove duplicates after you fetch data, i recommend to use lodash for working with arrays where is cool function uniq

    <ion-item class="wrapword" ng-repeat="object in allODLC2 | filter: searchQuery | orderBy:sortType:sortReverse | unique: 'caseFolderId'" href="#/app/detailOdla/{{object.id}}">

like that?

i’ll found a way…
ion-item class=“wrapword” ng-repeat=“object in allODLC2 | filter: searchQuery | orderBy:sortType:sortReverse " href=”#/app/detailOdla/{{object.id}}">

div ng-repeat=“row in [1] track by $index”>