user3677331
user3677331

Reputation: 698

Angular view not updating after $http call

I'm trying to get the list of stacks from my server and populate view with ng-repeat but for some reason the view doesn't update even though the scope is updated. Here's my code

    $scope.my = {stacks : []};
    $http.post('https://myurl',{"action":"login"}).success(function (data, status, headers, config) {
    $scope.my.stacks = data.stacks;
    console.log($scope.my.stacks); //logs the correct value
    //$scope.$apply() // don't need to do it, tried but it raised the already running digest cycle error
}).error(function (data, status){
    alert(data)
});

And here's my HTML

        //{{stacks}} if I do this, the view updates OK, strange
        <ion-slide-box on-slide-changed="slideHasChanged($index)">
        <ion-slide ng-repeat="stack in my.stacks">
            <div class="list card">
                <div class="item item-avatar">
                    <img src="./img/ionic.png">
                    <h2>{{stack.stack_name}}</h2>
                    <p>{{stack.stack_description}}</p>
                </div>
                <div class="item item-image">
                    <img style="max-width:100%;height:auto" src="./img/Test_Icon.png">
                </div>
                <a class="item item-icon-left assertive" ng-click="chooseStack(stack)">
                    <i class="icon ion-social-buffer-outline"></i>
                    Go to Stack
                </a>
            </div>
        </ion-slide>
    </ion-slide-box>

Also, the view updates as soon as I change the orientation. What am I doing wrong?

Upvotes: 2

Views: 156

Answers (1)

kolli
kolli

Reputation: 1290

The problem is the Ionic slidebox. You need to let it know that the scope variable has been updated as described here.

Upvotes: 2

Related Questions