Ng-repeat doesn't always update when $scope is updated

Hi all,

I’m having a slight issue with Ng-repeat. I have two views, the first one (Search) has a button which when clicked will add an item to $scope.results1 and then take the user to the other view (Results) where the ng-repeat is.

When I click the button and the results page comes up, only “1” is displayed. However, if I call the test function straight away in the controller, I get taken to the Results page and both “1” and “2” are displayed. In both cases, the console log shows that the array results1 contains 2 items.

What am I doing wrong?

Button in Search View :

<button class="button-full" id="find" ng-click="test();">Find</button>

SearchController:

 $scope.test = function(){
    $scope.results1.push(2);
    console.log("pushed 2");
    console.log($scope.results1);
    $state.go("tab.results");
  };

Results view:

  <ion-content ng-controller="SearchController">
    <body>
      <div id="results">
      <div class="list" id="search-items">
        <div ng-repeat="item in results1">
          {{item}}
        </div>
      </div>
    </div>
    </body>
  </ion-content>

Hi!

i have the same issue…

did you found a solution on this?
i already spent hours of time and i can’t find the right solution…
what i already tried:

  • view-cache=“false”
  • $scope.$apply() after the changes
  • before updating the array… i set the $scope.array.lenght = 0
    and maybe a lot of other things

but nothing works :frowning:

would be greate if somebody can help me out.

LG
Harald