“Duplicates in a repeater are not allowed” on ng-repeat

前端 未结 6 1981
野的像风
野的像风 2021-02-05 06:48

I\'ve got the following json data returned from a service request:

{
    \"entries\": [{
        \"id\": 2081,
        \"name\": \"BM\",
        \"niceName\": \"         


        
6条回答
  •  醉话见心
    2021-02-05 07:12

    It looks like you have a problem with the structure of the data in your scope. Your example JSON shows an object with an entries property and a count property. You then put that whole object in your scope as entries. This means you'd need to access the entries as entries.entries, with the count in entries.count. Perhaps this controller is closer to what you wanted:

    myApp.controller("MyController", ['$scope', '$http', '$log', function($scope, $http, $log){
        ...
    
        $http.get('https://myServiceURL').success(function(data){
            $scope.entries = data.entries;
            $scope.count = data.count;
        });
    }]);
    

提交回复
热议问题