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?

2
  • 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. Commented Oct 19, 2016 at 6:26
  • Did you try using unique filter?. See this answer Commented Oct 19, 2016 at 6:53

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.