AngularJs ng-repeat with long index (integer) throws error
up vote
0
down vote
favorite
I have two objects with the same date but with id . (double) :
{
id: 1541672305932,
date: 2018-01-01 11:11:11
}
{
id : 1541672305933,
date: 2018-01-01 11:11:11
}
and I got a duplicate error if the date is exactly the same
but if the id is simple id like . 1,2 its working I guess is the length of the id
how can I fix it ,, i have to use the id as the index
my ng repeat looks like
<li id="item_{{event.id}}" ng-repeat="event in list track by event.id">
error i got
Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: event in historyList track by event.id, Duplicate key: 1541672305932, Duplicate value:
{"date":"2018-11-08T10:18:25.000Z",id":1541672305932}
https://codepen.io/anon/pen/WYwbrv?editors=1010
angularjs angularjs-ng-repeat
|
show 3 more comments
up vote
0
down vote
favorite
I have two objects with the same date but with id . (double) :
{
id: 1541672305932,
date: 2018-01-01 11:11:11
}
{
id : 1541672305933,
date: 2018-01-01 11:11:11
}
and I got a duplicate error if the date is exactly the same
but if the id is simple id like . 1,2 its working I guess is the length of the id
how can I fix it ,, i have to use the id as the index
my ng repeat looks like
<li id="item_{{event.id}}" ng-repeat="event in list track by event.id">
error i got
Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: event in historyList track by event.id, Duplicate key: 1541672305932, Duplicate value:
{"date":"2018-11-08T10:18:25.000Z",id":1541672305932}
https://codepen.io/anon/pen/WYwbrv?editors=1010
angularjs angularjs-ng-repeat
there shouldn't be any duplicates, no matter the length. Can you double check the code you are posting
– Aleksey Solovey
Nov 8 at 10:08
yes i use timestamp with miliseconds and for sure of i chnaged the id its will be fine but part of the number is the same. maybe angular not supporting long id ?
– Tuz
Nov 8 at 10:16
2
The MAX_SAFE_INTEGER is 9,007,199,254,740,991 but your example is less than that. For more information, see MDNNumber.isSafeInteger()
– georgeawg
Nov 8 at 10:29
afterMath.pow(2, 53)
, their difference will not be counted, so you will have duplicates. Once again, double check your code, it should work
– Aleksey Solovey
Nov 8 at 10:40
@Tuz it works fine: codepen.io/karlen/pen/mQPdmx?editors=1010
– Karlen Kishmiryan
Nov 8 at 11:11
|
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have two objects with the same date but with id . (double) :
{
id: 1541672305932,
date: 2018-01-01 11:11:11
}
{
id : 1541672305933,
date: 2018-01-01 11:11:11
}
and I got a duplicate error if the date is exactly the same
but if the id is simple id like . 1,2 its working I guess is the length of the id
how can I fix it ,, i have to use the id as the index
my ng repeat looks like
<li id="item_{{event.id}}" ng-repeat="event in list track by event.id">
error i got
Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: event in historyList track by event.id, Duplicate key: 1541672305932, Duplicate value:
{"date":"2018-11-08T10:18:25.000Z",id":1541672305932}
https://codepen.io/anon/pen/WYwbrv?editors=1010
angularjs angularjs-ng-repeat
I have two objects with the same date but with id . (double) :
{
id: 1541672305932,
date: 2018-01-01 11:11:11
}
{
id : 1541672305933,
date: 2018-01-01 11:11:11
}
and I got a duplicate error if the date is exactly the same
but if the id is simple id like . 1,2 its working I guess is the length of the id
how can I fix it ,, i have to use the id as the index
my ng repeat looks like
<li id="item_{{event.id}}" ng-repeat="event in list track by event.id">
error i got
Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: event in historyList track by event.id, Duplicate key: 1541672305932, Duplicate value:
{"date":"2018-11-08T10:18:25.000Z",id":1541672305932}
https://codepen.io/anon/pen/WYwbrv?editors=1010
angularjs angularjs-ng-repeat
angularjs angularjs-ng-repeat
edited Nov 8 at 11:36
asked Nov 8 at 10:03
Tuz
164111
164111
there shouldn't be any duplicates, no matter the length. Can you double check the code you are posting
– Aleksey Solovey
Nov 8 at 10:08
yes i use timestamp with miliseconds and for sure of i chnaged the id its will be fine but part of the number is the same. maybe angular not supporting long id ?
– Tuz
Nov 8 at 10:16
2
The MAX_SAFE_INTEGER is 9,007,199,254,740,991 but your example is less than that. For more information, see MDNNumber.isSafeInteger()
– georgeawg
Nov 8 at 10:29
afterMath.pow(2, 53)
, their difference will not be counted, so you will have duplicates. Once again, double check your code, it should work
– Aleksey Solovey
Nov 8 at 10:40
@Tuz it works fine: codepen.io/karlen/pen/mQPdmx?editors=1010
– Karlen Kishmiryan
Nov 8 at 11:11
|
show 3 more comments
there shouldn't be any duplicates, no matter the length. Can you double check the code you are posting
– Aleksey Solovey
Nov 8 at 10:08
yes i use timestamp with miliseconds and for sure of i chnaged the id its will be fine but part of the number is the same. maybe angular not supporting long id ?
– Tuz
Nov 8 at 10:16
2
The MAX_SAFE_INTEGER is 9,007,199,254,740,991 but your example is less than that. For more information, see MDNNumber.isSafeInteger()
– georgeawg
Nov 8 at 10:29
afterMath.pow(2, 53)
, their difference will not be counted, so you will have duplicates. Once again, double check your code, it should work
– Aleksey Solovey
Nov 8 at 10:40
@Tuz it works fine: codepen.io/karlen/pen/mQPdmx?editors=1010
– Karlen Kishmiryan
Nov 8 at 11:11
there shouldn't be any duplicates, no matter the length. Can you double check the code you are posting
– Aleksey Solovey
Nov 8 at 10:08
there shouldn't be any duplicates, no matter the length. Can you double check the code you are posting
– Aleksey Solovey
Nov 8 at 10:08
yes i use timestamp with miliseconds and for sure of i chnaged the id its will be fine but part of the number is the same. maybe angular not supporting long id ?
– Tuz
Nov 8 at 10:16
yes i use timestamp with miliseconds and for sure of i chnaged the id its will be fine but part of the number is the same. maybe angular not supporting long id ?
– Tuz
Nov 8 at 10:16
2
2
The MAX_SAFE_INTEGER is 9,007,199,254,740,991 but your example is less than that. For more information, see MDN
Number.isSafeInteger()
– georgeawg
Nov 8 at 10:29
The MAX_SAFE_INTEGER is 9,007,199,254,740,991 but your example is less than that. For more information, see MDN
Number.isSafeInteger()
– georgeawg
Nov 8 at 10:29
after
Math.pow(2, 53)
, their difference will not be counted, so you will have duplicates. Once again, double check your code, it should work– Aleksey Solovey
Nov 8 at 10:40
after
Math.pow(2, 53)
, their difference will not be counted, so you will have duplicates. Once again, double check your code, it should work– Aleksey Solovey
Nov 8 at 10:40
@Tuz it works fine: codepen.io/karlen/pen/mQPdmx?editors=1010
– Karlen Kishmiryan
Nov 8 at 11:11
@Tuz it works fine: codepen.io/karlen/pen/mQPdmx?editors=1010
– Karlen Kishmiryan
Nov 8 at 11:11
|
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can try track by track by $index
instated of track by event.id
var app = angular.module('myApp', );
app.controller('myCtrl', function($scope) {
$scope.list =[
{
"id": '1234567894567',
"date": "2014-03-13T05:53:12 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
}
]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<li id="item_{{event.id}}" ng-repeat="event in list track by $index">{{event.id}}</li>
</div>
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can try track by track by $index
instated of track by event.id
var app = angular.module('myApp', );
app.controller('myCtrl', function($scope) {
$scope.list =[
{
"id": '1234567894567',
"date": "2014-03-13T05:53:12 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
}
]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<li id="item_{{event.id}}" ng-repeat="event in list track by $index">{{event.id}}</li>
</div>
add a comment |
up vote
0
down vote
You can try track by track by $index
instated of track by event.id
var app = angular.module('myApp', );
app.controller('myCtrl', function($scope) {
$scope.list =[
{
"id": '1234567894567',
"date": "2014-03-13T05:53:12 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
}
]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<li id="item_{{event.id}}" ng-repeat="event in list track by $index">{{event.id}}</li>
</div>
add a comment |
up vote
0
down vote
up vote
0
down vote
You can try track by track by $index
instated of track by event.id
var app = angular.module('myApp', );
app.controller('myCtrl', function($scope) {
$scope.list =[
{
"id": '1234567894567',
"date": "2014-03-13T05:53:12 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
}
]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<li id="item_{{event.id}}" ng-repeat="event in list track by $index">{{event.id}}</li>
</div>
You can try track by track by $index
instated of track by event.id
var app = angular.module('myApp', );
app.controller('myCtrl', function($scope) {
$scope.list =[
{
"id": '1234567894567',
"date": "2014-03-13T05:53:12 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
}
]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<li id="item_{{event.id}}" ng-repeat="event in list track by $index">{{event.id}}</li>
</div>
var app = angular.module('myApp', );
app.controller('myCtrl', function($scope) {
$scope.list =[
{
"id": '1234567894567',
"date": "2014-03-13T05:53:12 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
}
]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<li id="item_{{event.id}}" ng-repeat="event in list track by $index">{{event.id}}</li>
</div>
var app = angular.module('myApp', );
app.controller('myCtrl', function($scope) {
$scope.list =[
{
"id": '1234567894567',
"date": "2014-03-13T05:53:12 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
},
{
"id": '123456789789',
"date": "2014-12-15T01:32:39 -06:-30"
}
]
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<li id="item_{{event.id}}" ng-repeat="event in list track by $index">{{event.id}}</li>
</div>
answered Nov 8 at 10:53
Lakmi
9681823
9681823
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205404%2fangularjs-ng-repeat-with-long-index-integer-throws-error%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
there shouldn't be any duplicates, no matter the length. Can you double check the code you are posting
– Aleksey Solovey
Nov 8 at 10:08
yes i use timestamp with miliseconds and for sure of i chnaged the id its will be fine but part of the number is the same. maybe angular not supporting long id ?
– Tuz
Nov 8 at 10:16
2
The MAX_SAFE_INTEGER is 9,007,199,254,740,991 but your example is less than that. For more information, see MDN
Number.isSafeInteger()
– georgeawg
Nov 8 at 10:29
after
Math.pow(2, 53)
, their difference will not be counted, so you will have duplicates. Once again, double check your code, it should work– Aleksey Solovey
Nov 8 at 10:40
@Tuz it works fine: codepen.io/karlen/pen/mQPdmx?editors=1010
– Karlen Kishmiryan
Nov 8 at 11:11