Angular JS Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed

Angular JS Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed

我遇到了 [ngRepeat:dupes] 的问题。

systemService.getAllSystemSettings().then(
  function (obj) {
    $scope.project.meta.franchise = obj.find(item => item.keyword === "Program");
    console.log($scope.project.meta.franchise);
    $scope.project.meta.franchise = $scope.project.meta.franchise['keywordValue'].split(';');
    console.log($scope.project.meta.franchise);
    return $scope.project.meta.franchise);
  });

在我的 HTML 页面中:

<select class="form-control" ng-model="project.meta.franchise" ng-disabled="readOnlyUser">
  <option ng-repeat="option in project.meta.franchise" value="{{option}}">{{option}}</option>
</select>

控制台输出:

{ keyword: "Program", keywordValue: "test_abc;abc_&xyz;efg_&_hij"
}
[
  "test_abc",
  "abc_&xyz",
  "efg_&_hij"
]

控制台错误:

请帮我解决我试过按 $ index 放置轨道,但也没有解决方案。通过使用 $track by 它不会在选项中显示列表。提前谢谢你。

尝试像这样制作自定义唯一索引

<select class="form-control" ng-model="project.meta.franchise)" ng-disabled="readOnlyUser">
   <option ng-repeat="option in project.meta.franchise track by ($index + ':' + option)" value="{{option}}">{{option}}</option>
 </select>

尝试在 HTML select 语句中给出多个 = 'true'。请参考GitHub中的Davis Ford'spost。

尝试在您的 HTML 代码中将 ng-model 的值更改为 project.franchise。下面是我应用的代码,它对我有用:-

<select class="form-control" ng-model="project.franchise" ng-disabled="readOnlyUser">
  <option ng-repeat="option in project.meta.franchise)" value="{{option}}">{{option}}</option>
</select>