Tabs template list not clearing/refreshing data


Having an issue with actually clearing out and refreshing list items within a tab view.

A) Within the service, ‘refresh’ sets the return object to null (verified) calls for fresh data (verified) and returns it to the controller (verified).

B) Within the controller, before ‘refresh’ is called, i validate the length of the previously returned object(verified as length of 6), then set the object to null (verified as null), refresh the data and then validate the returned object (verified as length of 6 again).

My expectation is for the original list of 6 items to clear out and be replaced with the new list of 6 items. However, the html template list of 6 items grows to a list of 12, basically duplicating the original list. Further more, the new list of 12 seems to be sorted so the duplicates are listed in order as pairs - which seems like its being sorted. I don’t understand this behavior and I can’t figure out how to get displayed list to actually clear out.

    $scope.doRefresh = function() {
      alert(Object.keys($scope.prods).length) ;  // (6)
      $scope.prods= {} ;
      alert(Object.keys($scope.prods).length) ;  // (0)
      $scope.prods= Prods.refresh();
      alert(Object.keys($scope.prods).length) ;  // (6)

   refresh: function() {
     prods= [] ;
     getProds() ;
     return prods;


I figured it out. It was my own doing. in getProds() I wasn’t resetting the return objects to null, which is ultimately passed out to “prods”. so every time I hit refresh, the object in getProds()s was doubling in size, then being passed out to"prods". grrr…hate it when I beat myself up.