iHaveTooLearn_ImSoSorry iHaveTooLearn_ImSoSorry - 2 years ago 114
AngularJS Question

ng-repeat doesnt loop thru my array

Hey everybody can somebody please give me a clue what im doing wrong here?

I trying to build a wrapper where every element in my array gets a and a id
But when i loop thru my real array i only get a error with the text: Error: [ngRepeat:dupes] ...

With a fake array i made it works perfect.


<div class="translaterBox">
<span ng-repeat="person in persons" id="{{person}}">
{{person + " "}}

<span ng-repeat="text in textWords" id="{{text}}">
{{text + " "}}


var app = angular.module('splitScreenApp', []);
app.controller('splitCtrl', function ($scope, $http) {
$scope.translatetText = "Translate Here";

.then(function (response) {
var content = response.data.content;
$scope.content = content;

function splitContentToWords() {
var text;
for(var i = 0; i <= content.length;i++ ){
var text = content[i].text;
return text.split(' ');

$scope.persons = [
$scope.textWords = splitContentToWords();

Thank you really much for your help

Answer Source

When you get an error about dupes from Angular, it is because there are duplicate keys. You can solve this by using track by as seen in the documentation.

Try changing your ng-repeat to:

<span ng-repeat="person in persons track by $index" id="{{person}}">
<span ng-repeat="text in textWords track by $index" id="{{text}}">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download