Dinshaw Raje
Dinshaw Raje

Reputation: 963

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

I am facing an issue of [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);
  });

in my HTML page :

<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>

Output in console :

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

error in console:

enter image description here

Please help me out in solving I tried putting track by $ index but no solution with that too. By using $track by it does not show the list in options. ThankYou in advance.

Upvotes: 1

Views: 70

Answers (3)

Rachita Singhal
Rachita Singhal

Reputation: 79

Try changing the value of the ng-model to project.franchise in your HTML code. Below is the code I applied and it worked for me:-

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

Upvotes: 1

krishna ram
krishna ram

Reputation: 105

Try giving multiple = 'true' in your HTML select statement. Please refer to Davis Ford's post in GitHub regarding the same.

Upvotes: 0

FarukT
FarukT

Reputation: 1668

try to make a custom unique index like this

<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>

Upvotes: 1

Related Questions