错误:ngRepeat:dupes Repeater中的重复密钥(即使数据中没有重复)

时间:2018-09-25 14:56:43

标签: angularjs angularjs-ng-repeat

<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,并且其中没有重复项,但是在Repeater中有角度地抛出了重复密钥。
我已经尝试过track by $index,但这无济于事。

1 个答案:

答案 0 :(得分:0)

不确定代码中有什么问题,除非您将整个代码粘贴到此处,否则将很难回答。

我已根据您的问题为您创建了代码。

看看,让我知道。

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>