Ошибка: ngRepeat: дублирует дублирующийся ключ в репитере (даже если в данных нет дубликатов) - PullRequest
0 голосов
/ 25 сентября 2018
<div ng-repeat="item in skippedFiles.openCategories">

{{skippedFiles.openCategories}} печатает:

[
  {
    "name": "Files with Code Differences",
    "description": "Customizedfiles in which the code is different between the instance record and  the platform record",
    "sys_id": "undefined"
  },
  {
    "name": "Files Deleted in  the Instance",
    "description": "Files which have been deleted by a developer or system administrator during thecustomization of out-of-box code",
    "sys_id": "49e13d4113b8e3442a393ac2e144b0e9"
  },
  {
    "name": "Files Deleted in Platform",
    "description": "Files which are no longer a part of a platform release, resulting in deletion of file",
    "sys_id": "6912358113b8e3442a393ac2e144b025"
  }

Я проверил JSON, и в нем нет дубликатов, но угловые выбрасывают Duplicate Key в Repeater.
Я пробовал track by $index, ноэто не помогает.

1 Ответ

0 голосов
/ 25 сентября 2018

Не уверен, что не так в вашем коде, если вы не вставите здесь весь код, будет сложно ответить.

Я создал код для вас на основе вашего вопроса.

Естьпосмотри и дай мне знать.

function LoginController($scope) {
    $scope.user = {
        firstName: "Foo",
        lastName: "Bar"
    };
    $scope.skippedFiles = {};
    $scope.skippedFiles.openCategories = [
  {
    "name": "Files with Code Differences",
    "description": "Customizedfiles in which the code is different between the instance record and  the platform record",
    "sys_id": "undefined"
  },
  {
    "name": "Files Deleted in  the Instance",
    "description": "Files which have been deleted by a developer or system administrator during thecustomization of out-of-box code",
    "sys_id": "49e13d4113b8e3442a393ac2e144b0e9"
  },
  {
    "name": "FilesDeleted in Platform",
    "description": "Files which are no longer a part of a platform release, resulting in deletion of file",
    "sys_id": "6912358113b8e3442a393ac2e144b025"
  }
]    
};
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app ng-controller="LoginController">
    <div>Hello {{ user.firstName }}</div>
    <div ng-repeat="item in skippedFiles.openCategories">
    {{item.name}}
    {{item.description}}
    </div>
</div>
...