javascript - Error when repeating information from array in a new array -


error console:

error: [ngrepeat:dupes] duplicates in repeater not allowed. use 'track by' expression specify unique keys. repeater: m in diff, duplicate key: object:131, duplicate value: {"title":"diamond push up","vid":"img/3mm.mp4","time":60,"cal":3,"reps":20}

any workarounds above error?

$scope.moves = [     {title:"jumping jacks", length:"30", difficulty: "5 stars"},     {title:"push ups", length:"40", difficulty: "4 stars"},     {title:"mountain climbers", length:"60", difficulty: "2 stars"}     ]; 

this works

$scope.workoutone =[ $scope.moves[0], $scope.moves[1], $scope.moves[2], ]; 

this not work, obvious difference repeating information

$scope.workouttwo =[ $scope.moves[2], $scope.moves[1], $scope.moves[2], $scope.moves[0], $scope.moves[1], $scope.moves[2], ]; 

is there work around using same information array multiple times in new array? in advance help

edit (the html displayed user): apologies being vague! user see workoutone can choose, clicking button, view other workouts such workouttwo. workoutone shows fine (code below) user clicks workouttwo, information not refresh. , when user clicks start workout, goes through each move in workout, outputs "nan".

this code show workouts

<ion-list>  <ion-item ng-repeat="m in workoutchoice" class="eachitem">       <div class="animateded slideinup" style="width:90%;max-width:450px;height:45px;margin-left:auto;margin-right:auto;background-color:white;border:0px solid black;color:red;border-radius:7px;">           <div style="height:100%;float:left;border:0px solid blue;">             <img src="img/1-2.jpg" style="height:100%;align:center;border-radius:7px;">            </div>            <div style="width:40%;height:100%;float:left;border:2px solid blue;margin-top:8px;margin-left:5px;font-size:12px;">             {{m.title}}           </div>            <div style="width:25%;height:100%;float:right;border:2px solid red;text-align:right;margin-right:10px;color:black;margin-top:8px;font-size:12px;">             {{m.reps}}x           </div>     </div>    </ion-item> </ion-list> 

and code button allows different choices of workouts

  <div style="width:100%;height:50px;background-color:white;border:2px solid transparent;">     <div style="width:330px;border:2px solid transparent;margin-left:auto;margin-right:auto;margin-top:-10px;">         <img src="{{bub[3]}}" style="height:25px;margin-top:15px;float:left" ng-click="choosen(workoutone);">         <img src="{{bub[4]}}" style="height:25px;margin-top:15px;margin-left:31px;" ng-click="choosen(workouttwo);">       </div>    </div> 

another edit (js function called)

$scope.bubble = function(selectedcal) {   $rootscope.bub = selectedcal;   console.log(selectedbook); }  $scope.choosen = function(selectedchoose) {   $rootscope.workoutchoice = selectedchoose;   console.log(selectedchoose);   $ionicscrolldelegate.resize(); } 

hey have received same error many times. avoid duplicate error use $index in ng-repeat.

<ion-list>  <ion-item ng-repeat="m in workoutchoice track $index" class="eachitem">   <div class="animateded slideinup" style="width:90%;max-width:450px;height:45px;margin-left:auto;margin-right:auto;background-color:white;border:0px solid black;color:red;border-radius:7px;">       <div style="height:100%;float:left;border:0px solid blue;">         <img src="img/1-2.jpg" style="height:100%;align:center;border-radius:7px;">        </div>        <div style="width:40%;height:100%;float:left;border:2px solid blue;margin-top:8px;margin-left:5px;font-size:12px;">         {{m.title}}       </div>       <div style="width:25%;height:100%;float:right;border:2px solid red;text-align:right;margin-right:10px;color:black;margin-top:8px;font-size:12px;">             {{m.reps}}x           </div>     </div>    </ion-item> </ion-list> 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -