2

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?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.