0

I get data with ajax, then i need to display it in my view and use isotope on DOM elements which i get with ng-repeat. So, i need to call $scope.$apply(); Then i get error: "digest already in progress".

I tried to use "safe-apply", but scope's phase is always digest, so apply do not fires. All i need is sort of callback of ng-repeat.

Now i have something like this:

 $http({
    method: 'GET',
    url: '/web/main/json'
}).success(function (data, status, headers, config) {
        $scope.cards = data.cards;

        /* without this apply my DOM elements would be 
        invisible (if i use isotope on them)*/
        $scope.$apply(); 
        mainFunction(); // here i use isotope on my DOM elements
    }).error(function (data, status, headers, config) {
        alert("fail " + data);
    });
Semyon Danilov
  • 1,693
  • 1
  • 16
  • 35

2 Answers2

1

I think you should change your approach. Read about directives and write directive apply-isotope that applies isotope to children of tag it is used in and then create something like:

<tag1 apply-isotope>
  </tag2 ng-repeat="card in cards">
    ...
  </tag2>
</tag1>
p2004a
  • 123
  • 2
  • 7
0

Try like this.

$http({method: 'GET',
   url: '/web/main/json',
   **headers: { "Content-Type": "application/json; charset=UTF-8"}**
   }).success(){}).error(function () {});
Simon O'Doherty
  • 8,838
  • 1
  • 25
  • 46