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










share|improve this question
























  • 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















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










share|improve this question
























  • 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













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










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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
















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












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>








share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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
































    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>








    share|improve this answer

























      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>








      share|improve this answer























        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>








        share|improve this answer












        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>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 8 at 10:53









        Lakmi

        9681823




        9681823






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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




















































































            Popular posts from this blog

            Schultheiß

            Liste der Kulturdenkmale in Wilsdruff

            Android Play Services Check