Search code examples
javascriptangularjsangularjs-ng-repeat

Angular Js - Avoid repetition in ng-repeat


I am developing the system for Hotel POS solution. I want to fetch all the current orders and show the table number of orders only once.

But the table number is repeating for all the orders I have written following code :

<span ng-repeat='orders in allCurrentOrder'  ng-if='orders.custId==ctrl.person" + scope.divId + ".selected.cust_id && orders.orderType=="+scope.orderType+"'>Table No. : {{orders.tableNumber}}</span>

and I want output as :

Table No. : 9

but I am getting

Table No. : 9Table No. : 9Table No. : 9Table No. : 9Table No. : 9Table No. : 9Table No. : 9

how can I solve this problem?


Solution

  • Use track by:
    ng-repeat='orders in allCurrentOrder track by orders.tableNumber'