1

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?

Rohit Ghotkar
  • 803
  • 5
  • 17
  • There is $index available with ng-repeat you can make condition based on $index and if your matched index found then only you can print table number. – Ashish Panchal Oct 19 '16 at 06:26
  • Did you try using `unique` filter?. See [this](http://stackoverflow.com/a/15941016/4331291) answer – Nishant123 Oct 19 '16 at 06:53

2 Answers2

4

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

After Class
  • 58
  • 1
  • 2
0
<span ng-repeat='orders in allCurrentOrder track by $index'  ng-if='orders.custId==ctrl.person" + scope.divId + ".selected.cust_id && orders.orderType=="+scope.orderType+"'>Table No. : {{orders.tableNumber}}</span>
QI.soa
  • 117
  • 10