0

So, the following works when I run it on a local server:

html

<div class="container" ng-controller="TheController">
    <ul id="grid" class="grid">
        <li ng-repeat="guy in info">
            <a href="#">
                <img ng-src="{{ guy.img }}" alt="{{ guy.name }}">
                <p class="guy-name">{{ guy.name }}</p>
            </a>
        </li>
    </ul>
</div> 

js -- and I'm doing something like this in my controller:

        $http({ method: 'GET', url: 'data.json'}).success(function(data) {
            $scope.info = data;
        });

data

[
  {
    "img":"someImg.jpg",
    "name":"Paul Saul",
    "title":"Boss"
  },
  {
    "img":"anotherImg.jpg",
    "name":"Karalyn",
    "title":"Web"
  },
  {
    "img":"img.jpg",
    "name":"Derp",
    "title":"Retail"
  }
]

But when I run it in production I get a ngRepeat:dupes error. Any ideas why? I've tried to add track by $index as suggested in the docs and the error goes away but doesn't render the data and infinitely creates blank DOM nodes. Already read through the similar questions on SO, but can't seem to figure this out. I repeat, the above works locally with no errors; live it throws the error.

Community
  • 1
  • 1
davidpm4
  • 562
  • 1
  • 7
  • 22
  • When you change scope's variables with async ways(i think $http is async) you need to use `$scope.apply()` after all assignments. You can try to use **apply** method. – Engin Üstün Mar 03 '15 at 00:21
  • trying $scope.$apply() just throws an [inprog error](https://docs.angularjs.org/error/$rootScope/inprog?p0=$digest) – davidpm4 Mar 03 '15 at 00:50
  • 1
    I would look at what your production server is returning. It sounds like it might be returning an array of [undefined, undefined] or [null, null] or similar. Just point your browser to http://productionserver/data.json to verify that the data being sent down is valid. – Joe Enzminger Mar 03 '15 at 01:34
  • @JoeEnzminger, the data was being blocked by the server. So, there's that, which is nice. – davidpm4 Mar 03 '15 at 01:53
  • Been there, done that! – Joe Enzminger Mar 03 '15 at 01:55

0 Answers0